0

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

“将图像上传到 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 ...我做错了什么?

4

1 回答 1

5

没关系...变量“pictureName”为零...我羞愧地溜走了

于 2012-10-04T05:17:57.043 回答