我从url下载一个图像到一个ec2实例(Wget),用imagemagick (转换-actions $savedfilename)处理它,然后将它保存到s3 (使用php )。
发布于 2012-06-16 11:23:34
我猜你的意思是"...without给EBS卷写信“,对吗?您可以将Wget输出直接输送到ImageMagicks转换,如下所示:
wget -O - 'http://d24w6bsrhbeh9d.cloudfront.net/photo/4498158_700b_v1.jpg' | convert - test.png看看s3cmd,它将允许您直接从命令行与S3交互。然后,我们的示例工作流将如下所示:
wget -O - 'http://d24w6bsrhbeh9d.cloudfront.net/photo/4498158_700b_v1.jpg' | convert - test.png && s3cmd put --acl-public --guess-mime-type test.png s3://example.com/images/test.png这将给出这个结果,您可以使用regex对其进行筛选以获得公共URL:
File 'test.png' stored as s3://example.com/images/test.png (xxxx bytes)
Public URL of the object is: http://example.com.s3.amazonaws.com/images/test.png从文本中获取URL:
<?php
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
$cmd_output = "File 'test.png' stored as s3://example.com/images/test.png (xxxx bytes) Public URL of the object is: http://example.com.s3.amazonaws.com/images/test.png";
if(preg_match($reg_exUrl, $cmd_output, $url)) {
$image_url = $url[0];
}
else {
// no url found …
}
?>我想这是一种优雅的处理方法:)我不确定它是否会更快或更便宜的…也许有一点是因为EBS的磁盘I/O不好。
发布于 2017-08-11 15:36:21
来自aws s3 cli cp文档
将本地文件流上载到S3 警告: PowerShell可能更改CRLF的编码或添加到管道输入。 以下cp命令将本地文件流从标准输入上载到指定的桶和键: aws s3 cp-S3://mybucket/Stream.txt
就像“多姆”的回答一样
wget -O - 'http://d24w6bsrhbeh9d.cloudfront.net/photo/4498158_700b_v1.jpg' | convert - test.png | aws s3 cp - s3://example.com/images/test.png --acl publichttps://stackoverflow.com/questions/11062494
复制相似问题