简体   繁体   English

iOS AWS开发工具包将覆盖Content-Type属性

[英]iOS AWS SDK overrides the Content-Type property

I am trying to set the Content-Type property of my file as follows but when I inspect the file in the web, the content-type is reset to application/octet-stream 我试图按以下方式设置文件的Content-Type属性,但是当我在网络上检查文件时,内容类型被重置为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];

At the filepath resides a NSData written to a file with a UUID as filename (no file extension). 在文件路径中驻留了一个NSData,该数据以UUID作为文件名(没有文件扩展名)写入文件。

Any leads would be appreciated 任何线索将不胜感激

I have found a workaround for this problem. 我已经找到解决此问题的方法。 Instead of providing the filename, I proved the data to the S3PutObjectRequest 我没有提供文件名,而是将数据证明给了S3PutObjectRequest

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM