![](/img/trans.png)
[英]Background image (Background Mode) uploading in Amazon S3 bucket without using AWS SDK in iOS Swift
[英]IOS AWS s3 bucket image uploading problems
一直在尝试使它工作一段时间,因为我已经尝试使用数据和流技术但没有运气,我认为我不需要创建大多数示例中所示的存储桶,因为我想上传到的存储桶已经存在,它还会告诉我我要访问的存储区,但是当我尝试上传时,我得到了
“将图像上传到S3时出错:您提供的XML格式不正确或未针对我们发布的模式进行验证”
这是代码
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);
}
太...我在做什么错?
没关系...变量“ pictureName”为零...我羞愧地溜走了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.