[英]how to upload image to asw s3
I am uploading image from the following code - 我正在从以下代码上传图像-
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
AmazonS3Client *s3Client = [[[AmazonS3Client alloc] initWithAccessKey:ACCESS_KEY_ID withSecretKey:SECRET_KEY] autorelease];
s3Client.timeout = 240;
NSString *bucketName = [NSString stringWithFormat:@"test/images/"];
NSString *imageName = [NSString stringWithFormat:@"testimage.jpg"];
S3PutObjectRequest *objReq = [[S3PutObjectRequest alloc] initWithKey:imageName inBucket:bucketName];
objReq.contentType = @"image/jpeg";
objReq.data = imageData;
objReq.delegate = self;
objReq.contentLength = [imageData length];
[s3Client putObject:objReq];
I am getting following error - 我收到以下错误-
S3Response.m|-[S3Response connection:didFailWithError:]|234|UserInfo.NSUnderlyingError = Error Domain=kCFErrorDomainCFNetwork Code=-1003 "A server with the specified hostname could not be found." S3Response.m |-[S3Response连接:didFailWithError:] | 234 | UserInfo.NSUnderlyingError =错误Domain = kCFErrorDomainCFNetwork代码= -1003“找不到具有指定主机名的服务器。” UserInfo=0xac62aa0
{NSErrorFailingURLKey=https://test/images/.s3.amazonaws.com/testimage.jpg
UserInfo = 0xac62aa0
{NSErrorFailingURLKey=https://test/images/.s3.amazonaws.com/testimage.jpg
Please suggest me what i am doing wrong. 请建议我我在做什么错。
in bucketName
you are storing the path to the folder within your bucket. 在
bucketName
您将存储到存储桶中文件夹的路径。 You need to only have your bucket name there. 您只需要在其中输入存储桶名称。
It should be: https://bucketname.s3.amazonaws.com/test/images/testimage.jpg
它应该是:
https://bucketname.s3.amazonaws.com/test/images/testimage.jpg
: https://bucketname.s3.amazonaws.com/test/images/testimage.jpg
Your's is: https://test/images/.s3.amazonaws.com/testimage.jpg
您的是:
https://test/images/.s3.amazonaws.com/testimage.jpg
See the problem? 看到问题了吗? test/images/.s3.amazonaws.com is not a valid domain name.
test / images / .s3.amazonaws.com不是有效的域名。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.