Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you provide an example of how to do a file upload? #5

Open
coler-j opened this issue Feb 2, 2017 · 1 comment
Open

Can you provide an example of how to do a file upload? #5

coler-j opened this issue Feb 2, 2017 · 1 comment

Comments

@coler-j
Copy link

coler-j commented Feb 2, 2017

Hello,
Wondering if you have a code example of how to do a file upload with Django (getting the file from the user, maybe examining it, and then uploading to gcs).

@eSilva95
Copy link

im trying to upload pdf files but i get Server Error (500)

my function to upload files in my views.py is:
def uploadFiles(request, id):
if not request.user.is_superuser and request.user.is_staff:
if request.method == 'POST':
form = StudentFilesForm(request.POST, request.FILES)
if form.is_valid():
form.save()
return redirect('detailRequest', id)
so, which can be the problem i have?

there are my vars in my settings.py:

if os.getenv('GAE_APPLICATION', None):
GOOGLE_CLOUD_STORAGE_BUCKET = 'media_examenes_sinodales' # the name of the bucket you have created from the google cloud storage console
GOOGLE_CLOUD_STORAGE_URL = 'https://console.cloud.google.com/storage/browser/media_examenes_sinodales' #'http://storage.googleapis.com/bucket' #whatever the ulr for accessing your cloud storgage bucket
GOOGLE_CLOUD_STORAGE_DEFAULT_CACHE_CONTROL = 'public, max-age: 7200' # default cache control headers for your files
DEFAULT_FILE_STORAGE = 'django_google_cloud_storage.GoogleCloudStorage'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants