使用Google App Engine PHP的临时文件的最佳解决方案/做法? [英] Best solution / practice for temp files with Google App Engine PHP?

查看:61
本文介绍了使用Google App Engine PHP的临时文件的最佳解决方案/做法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请问使用PHP在GAE上普遍接受的关于临时文件的智慧/技术解决方案是什么?

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

我需要使用PHP存储和处理图像(大小为几百K),该图像需要暂时(例如<1秒)作为临时文件存在,然后再发送到其他地方,并且可以删除该临时文件.我的网站将需要自动扩展以适应潜在的大量用户(使用GAE作为标准).

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).

我的想法是尝试将临时文件存储在内存中(使用tempnam()等),如果失败(例如该实例的mem full),请立即尝试并使用其他一些存储来代替.问题是什么?图片必须作为文件提供给CURL才能访问它(我认为吗?)并发送到其他地方,因此Memcache不是一个选择(不能将数据作为文件访问以传递给CURL-还是可以吗?),但是例如云存储为(通过'gs://[bucket-name]/...').问题是,如果我刚刚将文件写入存储设备,它是否可以立即读取?这也是一笔可观的费用...

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...

任何帮助,不胜感激!

谢谢,亚历克斯

推荐答案

GCS还提供了默认的免费应用程序存储桶,该存储桶也与您的应用程序绑定.该存储桶没有配额.

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

使用默认存储桶

要使用默认存储桶:

确定您的应用是否已经创建了默认存储桶:

Determine whether your app already has the default bucket created:

  • 访问App Engine管理控制台,然后选择您的应用.
  • 在左侧导航窗格中选择应用程序设置".
  • 如果您的应用具有默认存储桶,应用程序设置"页面将包含标签Google Cloud Storage Bucket,并在其下方列出了存储桶名称.这默认存储桶名称通常是.appspot.com,其中是您的应用程序ID.

如果您的应用没有默认存储桶,创建一个:

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

  • 访问App Engine管理控制台,然后选择您的应用.
  • 在左侧导航窗格中选择应用程序设置",然后滚动到页面底部到Cloud Integration
  • 点击创建并等待要创建的存储桶.铲斗已完全安装好并准备就绪使用.

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

这篇关于使用Google App Engine PHP的临时文件的最佳解决方案/做法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆