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

GCP: File Field saved files successfully but in database it's null #972

Closed
Iamsdt opened this issue Dec 26, 2020 · 1 comment
Closed

GCP: File Field saved files successfully but in database it's null #972

Iamsdt opened this issue Dec 26, 2020 · 1 comment

Comments

@Iamsdt
Copy link

Iamsdt commented Dec 26, 2020

I am working on a project, that hosted on GCP Compute Instance VM. But when upload and save any file into the File Field, it's saving that file in google cloud storage successfully. And it's showing
"The table was added successfully. " But if I open any saved data again, the file picker field showing the save option as blank and there is no saved file. I am accessing this table using rest API, and this file picker field coming as null.

Here is my code -

setting.py

DEFAULT_FILE_STORAGE = 'storages.backends.gcloud.GoogleCloudStorage'
GS_BUCKET_NAME = '<bucket-name>"'

here is the model code

class UserTable(models.Model):
        image_url = models.FileField(upload_to='user_pic//%Y/%m', blank=True)

Screenshot During data save
image
When I open any saved object, it looks like this way
image

Libraries and Versions

  1. Django -> 3.1.2
  2. djangorestframework -> 3.12.1
  3. django-storages -> 1.11.1
@sww314
Copy link
Contributor

sww314 commented Dec 29, 2020

@Iamsdt my guess is your file is actually uploading and saved in the database fine. The issue is actually on retrieval when you try to generate a signed url.

#941
This issue is written specific to Cloud Run, but I think problem is easy to run into with the wrong permissions.

@Iamsdt Iamsdt closed this as completed Mar 12, 2022
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