iOS AWS SDK会覆盖Content-Type属性

时间:2017-11-28 14:35:26

标签: ios objective-c amazon-web-services amazon-s3

我正在尝试按如下方式设置文件的Content-Type属性,但是当我在Web中检查文件时,内容类型将重置为application/octet-stream

    S3PutObjectRequest *request = [[S3PutObjectRequest alloc] initWithKey:key inBucket:bucket];
    request.filename            = filePath;
    request.contentType         = [self mimeTypeForFileAtPath:operation.filePath]; //Returns @"image/jpeg"
    operation.operation         = [self.manager upload:request];

在文件路径中存在写入文件的NSData,其中UUID为文件名(无文件扩展名)。

任何线索都将受到赞赏

1 个答案:

答案 0 :(得分:0)

我找到了解决此问题的方法。我没有提供文件名,而是将数据证明为S3PutObjectRequest

request.data                = [NSData dataWithContentsOfFile:operation.filePath];
request.contentType         = [self mimeTypeForFileAtPath:operation.filePath];