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

Django project deployed to GCP App Engine returns [Errno 30] Read-only file system when uploading an image #1185

Closed
HitLuca opened this issue Oct 5, 2022 · 2 comments

Comments

@HitLuca
Copy link

HitLuca commented Oct 5, 2022

Tried to look for solutions but I don't seem to have found any, so I'm opening a new issue:
I have a django project which uses a gcp bucket for images upload. Locally it works fine, but when deployed on GCP App Engine and I try to upload an image I get this exception

[Errno 30] Read-only file system: '/workspace/media'

I am confident my env vars are correct and the django-storages library gets set up correctly at startup, but I really can't understand why the backend is trying to access the local filesystem instead of uploading the image. The bucket setup code is below:

if env("USE_BUCKET_AS_MEDIA_FOLDER"):
    # Set "media" folder
    DEFAULT_FILE_STORAGE = "myproject.gcsutils.Media"

    GS_BUCKET_NAME = env("MEDIA_FOLDER_BUCKET_NAME")

    # Add an unique ID to a file name if same file name exists
    GS_FILE_OVERWRITE = False

    GCP_CREDENTIALS = env("GCP_CREDENTIALS")

    GS_CREDENTIALS = service_account.Credentials.from_service_account_info(
        json.loads(GCP_CREDENTIALS)
    )

And here are the contents of myproject.gcsutils.py

from storages.backends.gcloud import GoogleCloudStorage

def Media():
    return GoogleCloudStorage(location="media")

Happy to add any useful details, any help would be very appreciated

@jschneier
Copy link
Owner

A SpooledTemporaryFile is used as the backing storage which will rollover to disk at a configurable amount. However, the default is to not rollover at all. You haven't set that GS_MAX_MEMORY_SIZE setting, have you?

If not, a larger stack trace would be helpful.

@jschneier
Copy link
Owner

Need more info.

@jschneier jschneier closed this as not planned Won't fix, can't repro, duplicate, stale Sep 4, 2023
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