0

我正在从以下代码上传图片 -

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];

我收到以下错误 -

S3Response.m|-[S3Response connection:didFailWithError:]|234|UserInfo.NSUnderlyingError = 错误域=kCFErrorDomainCFNetwork 代码=-1003 “找不到具有指定主机名的服务器。” 用户信息=0xac62aa0{NSErrorFailingURLKey=https://test/images/.s3.amazonaws.com/testimage.jpg

请告诉我我做错了什么。

4

1 回答 1

0

bucketName您存储存储桶中文件夹的路径。您只需要在那里有您的存储桶名称。

它应该是: https://bucketname.s3.amazonaws.com/test/images/testimage.jpg

你的是: https://test/images/.s3.amazonaws.com/testimage.jpg

看到问题了吗?test/images/.s3.amazonaws.com 不是有效的域名。

于 2013-08-21T13:51:25.027 回答