我尝试使用 SDK 版本 3 将图像上传到 S3 存储桶,但我收到以下错误:
Error executing "PutObject" on "https://s3.Ireland.amazonaws.com/my-bucket-name/testFile.jpg"; AWS HTTP error: cURL error 6: Couldn't resolve host 's3.Ireland.amazonaws.com' (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
这是我第一次尝试这样做,所以我没有太大的信心。
通过AWS接口(interface)上传文件,其URL类似于https://s3-eu-west-1.amazonaws.com/my-bucket-name/testFileThroughWeb.jpg。
因此,它似乎不同于 AWS SDK 创建的 PUT 文件(即 https://s3.Ireland.amazonaws.com/my-bucket-name/testFile.jpg )
我想指出的另一件事是我传递给 S3Client 的构造函数的版本。
它的实例是通过传递给键 version 的值 stable 而在存储桶策略中我使用 version: "2012-10-17".
这是桶策略的配置:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AddPerm",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:*",
"Resource": "arn:aws:s3:::my-bucket-name/*"
}
]
}
要将图像保存在存储桶中,我使用以下代码:
public function testS3Action()
{
$fileToUpload = 'http://example.com/an/image.jpg';
// Get the remote file extension
$remoteImageExtension = explode('.', $fileToUpload);
$remoteImageExtension = array_pop($remoteImageExtension);
$fs = new Symfony\Component\Filesystem\Filesystem();
$tempImage = tempnam(sys_get_temp_dir(), 'image.') . '.' . $remoteImageExtension;
/**
* From the Symfony container
* @var GuzzleHttp\Client $client
*/
$client = $this->get('guzzle.client');
// Get and save file
$client->get($fileToUpload, ['save_to' => $tempImage]);
$tempImage = new Symfony\Component\HttpFoundation\File\File($tempImage);
/**
* From the Symfony container
* @var Aws\S3\S3Client $s3
*/
$s3 = $this->get('shq.amazon.s3');
$params = [
'Bucket' => $this->getParameter('amazon.s3.bucket'),
'Key' => 'testFile.jpg',
'Body' => $tempImage
];
$result = $s3->putObject($params);
return $result;
}
这可能是我收到错误的原因?为什么 S3Client 猜测的主机 https://s3.Ireland.amazonaws.com 不正确?
最佳答案
不存在“爱尔兰”这样的 AWS 区域。列出了 S3 的有效区域 on Amazon's web site ;您可能在此处尝试使用的是 EU(爱尔兰),它在区域参数中表示为 eu-west-1。
关于php - Aws PHP Sdk 3:S3::putObject():AWS HTTP 错误:cURL 错误 6:无法解析主机 's3.Ireland.amazonaws.com',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31777475/
我有一个字符串input="maybe(thisis|thatwas)some((nice|ugly)(day|night)|(strange(weather|time)))"Ruby中解析该字符串的最佳方法是什么?我的意思是脚本应该能够像这样构建句子:maybethisissomeuglynightmaybethatwassomenicenightmaybethiswassomestrangetime等等,你明白了......我应该一个字符一个字符地读取字符串并构建一个带有堆栈的状态机来存储括号值以供以后计算,还是有更好的方法?也许为此目的准备了一个开箱即用的库?
我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我正在使用ruby1.9解析以下带有MacRoman字符的csv文件#encoding:ISO-8859-1#csv_parse.csvName,main-dialogue"Marceu","Giveittohimóhe,hiswife."我做了以下解析。require'csv'input_string=File.read("../csv_parse.rb").force_encoding("ISO-8859-1").encode("UTF-8")#=>"Name,main-dialogue\r\n\"Marceu\",\"Giveittohim\x97he,hiswife.\"\
我在我的项目中添加了一个系统来重置用户密码并通过电子邮件将密码发送给他,以防他忘记密码。昨天它运行良好(当我实现它时)。当我今天尝试启动服务器时,出现以下错误。=>BootingWEBrick=>Rails3.2.1applicationstartingindevelopmentonhttp://0.0.0.0:3000=>Callwith-dtodetach=>Ctrl-CtoshutdownserverExiting/Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.1/lib/action_mailer
在MRIRuby中我可以这样做:deftransferinternal_server=self.init_serverpid=forkdointernal_server.runend#Maketheserverprocessrunindependently.Process.detach(pid)internal_client=self.init_client#Dootherstuffwithconnectingtointernal_server...internal_client.post('somedata')ensure#KillserverProcess.kill('KILL',
我已经从我的命令行中获得了一切,所以我可以运行rubymyfile并且它可以正常工作。但是当我尝试从sublime中运行它时,我得到了undefinedmethod`require_relative'formain:Object有人知道我的sublime设置中缺少什么吗?我正在使用OSX并安装了rvm。 最佳答案 或者,您可以只使用“require”,它应该可以正常工作。我认为“require_relative”仅适用于ruby1.9+ 关于ruby-主要:Objectwhenrun
我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳