限制AppEngine接口上传到云存储的文件大小。

huangapple go评论72阅读模式
英文:

Limit upload size for appengine interface to cloud store

问题

考虑一个将图像(头像)上传到Google Cloud Storage的功能,该功能将从用户的Web浏览器开始,然后通过一个Go appengine实例,该实例将处理标准的压缩/裁剪等操作,然后将生成的图像设置为Cloud Storage中的对象。

如何确保appengine实例不会被过多或错误的数据超载?换句话说,我认为我在问两个问题(或者可能不是两个问题):

  1. 如何限制在单个请求中允许发送到appengine实例的数据量,或者是否已经有一个默认的安全限制?

  2. 如何验证数据,以确保它是正确的jpg/png/gif格式,然后再尝试使用标准的Go图像库进行处理?

英文:

Consider an image (avatar) uploader to Google Cloud Storage which will start from the user's web browser, and then pass through a Go appengine instance which will handle standard compression/cropping etc. and then set the resulting image as an object in Cloud Storage

How can I ensure that the appengine instance isn't overloaded by too much or bad data? In other words, I think I'm asking two questions (or possibly not):

  1. How can I limit the amount of data allowed to be sent to an appengine instance in a single request, or is there already a default safe limit?

  2. How can I validate the data to make sure it's proper jpg/png/gif before attempting to process it with standard go image libraries?

答案1

得分: 0

  1. 所有的App Engine请求都限制在32MB以内。

  2. 在上传开始之前,你可以检查要上传的文件的大小。

  3. 你可以验证文件的MIME类型,只允许正确的文件被上传。

英文:
  1. All App Engine requests are limited to 32MB.

  2. You can check the size of the file being uploaded before the upload starts.

  3. You can verify the file's mime-type and only allow correct files to be uploaded.

huangapple
  • 本文由 发表于 2016年2月10日 05:04:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/35302160.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定