Best solution / practice for temp files with Google App Engine PHP?

佐手、 提交于 2021-02-08 10:21:12

问题


What's generally accepted wisdom/tech solution for temp files on GAE using PHP, please?

I need to store and process an image (a few hundred K in size) using PHP that momentarily (e.g. < 1 second) needs to exist as a temp file somewhere before it's sent on elsewhere and the temp file can be deleted. My site will need to autoscale for potentially large numbers of users (using GAE as standard).

My idea was to attempt to store the temp file in memory (using tempnam() etc) and if that failed (e.g. mem full on that instance), immediately try and use some other storage instead on the fly. Question is what? Image has to be available as a file for CURL to access it (I think?) and send elsewhere, so Memcache is not an option (can't access the data as a file to pass into CURL - or can I?), but e.g. Cloud Storage is (via 'gs://[bucket-name]/...'). Thing is, if I've just written the file to storage, is it immediately available for reading? That's also a significant cost incurred...

Any help much appreciated!

Thanks, Alex


回答1:


GCS provides a default application free bucket that is tied to your app as well. There is no quota for this bucket.

Using a default bucket

To use the default bucket:

Determine whether your app already has the default bucket created:

  • Visiting the App Engine Admin console and select your app.
  • Select Application Settings in the left navigation pane.
  • If your app has a default bucket, the Application Settings page will contain the label Google Cloud Storage Bucket, with the bucket name listed under it. The default bucket name is typically .appspot.com, where is your application ID.

If your app doesn't have a default bucket, create one:

  • Visit the App Engine Admin console and select your app.
  • Select Application Settings in the left navigation pane and scroll to the bottom of the page to Cloud Integration
  • Click Create and wait for the bucket to be created. The bucket is completely set up and ready for use.

ref: https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/activate#using_a_default_bucket



来源:https://stackoverflow.com/questions/30822218/best-solution-practice-for-temp-files-with-google-app-engine-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!