IOS AWS s3桶图像上传问题

时间:2012-09-25 06:25:02

标签: ios amazon-s3

一直试图让它工作一段时间知道我已经尝试了数据和流媒体但没有运气,我认为我不需要像大多数示例中所示创建存储桶作为我要上传的存储桶已经存在,它也告诉我我想要访问的存储桶,但是当我尝试上传时我得到了这个

“将图片上传到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);
    }

sooooo ......我做错了什么?

1 个答案:

答案 0 :(得分:4)

没关系......变量“pictureName”是零......我羞愧地甩掉了