Moving a file stored locally to amazon S3

随声附和 提交于 2019-12-22 10:45:18

问题


I have a script (PHP) that stores an image uploaded by a user to my server. After it is uploaded (which involves some processing) I want to move that processed file to S3.

Just to be clear, here is what I would like to achieve:

  1. Let user upload file to my server
  2. Process image (resize etc.)
  3. Move processed image to my S3 bucket with a specific dynamically generated name, eg. 123876542234.jpg
  4. Get out the address of the publicly accessible file in my S3 bucket

I have no experience with using S3 but have a strong grasp of PHP. I tried a few tutorials but none of them worked. Any help would be greatly appreciated.


回答1:


IF you download the SDK http://aws.amazon.com/sdkforphp/ they provide a few examples, and one of them is all about S3. It includes how to upload files to S3 using PHP.




回答2:


Make sure you get the newer version 2. It has a faster and more reliable HTTP layer, and uses modern concepts such as Iterators and Observers.

Here's some S3-specific documentation. https://github.com/aws/aws-sdk-php/blob/master/docs/service-s3.rst. Here's all of the other documentation. http://aws.amazon.com/documentation/sdkforphp2/




回答3:


With a strong grasp of PHP, I'd go straight to the AWS PHP SDK, which contains all the documentation you need to send a given file to S3 using the SDK's API: http://aws.amazon.com/sdkforphp/




回答4:


For the upload with S3, take a look at this similar topic File upload to Amazon S3 from PHP

and this posts

http://www.9lessons.info/2012/08/upload-files-to-amazon-s3-php.html http://net.tutsplus.com/tutorials/php/how-to-use-amazon-s3-php-to-dynamically-store-and-manage-files-with-ease/

Amazon doesn't charge you the bandwidth used for upload, but you may be wasting server processing time and your client's bandwidth.

I suggest you to use plupload, it is free and does all the image manipulation on the client side if you want to.

http://www.plupload.com/

HTH



来源:https://stackoverflow.com/questions/15170895/moving-a-file-stored-locally-to-amazon-s3

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