简体   繁体   English

将本地存储的文件移动到amazon S3

[英]Moving a file stored locally to amazon S3

I have a script (PHP) that stores an image uploaded by a user to my server. 我有一个脚本(PHP),用于存储用户上传到我的服务器的图像。 After it is uploaded (which involves some processing) I want to move that processed file to S3. 上传后(涉及一些处理)我想将处理后的文件移动到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. 将处理后的图像移动到具有特定动态生成名称的S3存储桶,例如。 123876542234.jpg 123876542234.jpg
  4. Get out the address of the publicly accessible file in my S3 bucket 获取我的S3存储桶中可公开访问的文件的地址

I have no experience with using S3 but have a strong grasp of PHP. 我没有使用S3的经验,但对PHP有很强的把握。 I tried a few tutorials but none of them worked. 我尝试了一些教程,但没有一个有用。 Any help would be greatly appreciated. 任何帮助将不胜感激。

IF you download the SDK http://aws.amazon.com/sdkforphp/ they provide a few examples, and one of them is all about S3. 如果您下载SDK http://aws.amazon.com/sdkforphp/,他们会提供一些示例,其中一个就是S3。 It includes how to upload files to S3 using PHP. 它包括如何使用PHP将文件上传到S3。

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. 确保获得更新的版本2.它具有更快,更可靠的HTTP层,并使用迭代器和观察者等现代概念。

Here's some S3-specific documentation. 这是一些特定于S3的文档。 https://github.com/aws/aws-sdk-php/blob/master/docs/service-s3.rst . 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/ http://aws.amazon.com/documentation/sdkforphp2/

掌握了PHP,我将直接使用AWS PHP SDK,其中包含使用SDK的API将给定文件发送到S3所需的所有文档: http//aws.amazon.com/sdkforphp/

For the upload with S3, take a look at this similar topic File upload to Amazon S3 from PHP 对于使用S3上传,请查看此类似主题从PHP上传到Amazon S3的文件

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/ 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到动态存储和管理,文件与-轻松/

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. 我建议你使用plupload,它是免费的,如果你愿意,可以在客户端进行所有图像处理。

http://www.plupload.com/ http://www.plupload.com/

HTH HTH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM