0
一直试图让这个工作一段时间知道我已经尝试过使用数据和流但没有运气,我假设我不需要创建如大多数示例中所示的存储桶作为我想要上传到存储桶,也告诉我我试图访问的桶,但是当我尝试上载时,我得到这个IOS AWS s3桶图像上传问题
“上传图像到S3时出错:你提供的XML不好-formed或没有验证对我们发布的架构”
这里是代码
UIImage * img = [[[[CurrentGamesInfo sharedCurrentGamesInfo]GameInCreation] GetImageToSend]_imageToSend];
NSData *savedImageData = UIImageJPEGRepresentation(img, 0.8);
NSString *pictureName = [[[CurrentGamesInfo sharedCurrentGamesInfo]GameInCreation] GetGameID];
@try
{
AmazonS3Client *s3 = [[[AmazonS3Client alloc] initWithAccessKey:MY_ACCESS_KEY_ID withSecretKey:MY_SECRET_KEY] autorelease];
//[s3 createBucket:[[[S3CreateBucketRequest alloc] initWithName:MY_PICTURE_BUCKET] autorelease]];
NSArray *bucketArray = [s3 listBuckets];
S3Bucket *bucket = [[s3 listBuckets] objectAtIndex:0];
NSLog(@"%@",[bucket name]);
S3PutObjectRequest *por = [[[S3PutObjectRequest alloc] initWithKey:pictureName inBucket:MY_PICTURE_BUCKET] autorelease];
por.contentType = @"image/jpeg";
//por.data = savedImageData;
//por.cannedACL = [S3CannedACL publicRead];
S3UploadInputStream *stream = [S3UploadInputStream inputStreamWithData:savedImageData];
//stream.delay = 0.2;
//stream.packetSize = 16;
por.contentLength = [savedImageData length];
por.stream = stream;
[s3 putObject:por];
}
@catch (AmazonClientException *exception)
{
NSLog(@"Error uploading image to S3: %@", exception.message);
}
sooooo ...我做错了什么?
不要羞愧,这实际上帮了我。 :)) – EladG
我很高兴我的编码人造颂的出版帮助了某人 – Genhain