1
votes

I have deployed a flask app on GCP app engine that I'm using for uploading files to GCP bucket storage and then download the file from the storage when required. However, I'm encountering the error OSError: [Errno 30] Read-only file system: when I try to download the file from cloud storage. I can properly upload the file from the app which I've deployed on app engine and I verified the file was uploaded, but when I try to download from the website I get error. Any idea would be appreciated?

Code for Downloading the File from Bucket

 storage_client = storage.Client()

 bucket = storage_client.bucket(bucket_name)
 blob = bucket.blob(source_blob_name)
 blob.download_to_filename(destination_file_name)

PS: I'm using google-cloud-storage==1.33.0

1
Sounds like the destination where you're trying to write the downloaded file is read-only. - John Gordon
@JohnGordon Thanks for the comment! Could you please provide guidance on how I can download it to specific folder? I tried specifiying the folder path using os.path but got another error :( - Alex
The usual way is to use f = open("/some/path/to/filename", "w") and then f.write(content). - John Gordon
Nope that doesn't help either.. still same error - Alex
Are you trying to download the files to your app or to an and user? If to your app, then the answer below works though also consider using BytesIO for an in-memory file if the files are not large. If to an end user, then you can provide the user with a link to download it directly from cloud storage and bypass your app. - gaefan

1 Answers

1
votes

There is no writable hard drive in App Engine, if you need to write a temporary file use /tmp folder as explained here. Don't forget to delete it to release system's RAM or it will crash at some point.