簡體   English   中英

土耳其語上的AWS S3 SDKv2和圖像上傳ios

[英]AWS S3 SDKv2 and image upload ios on turk

我使用以下代碼將圖像上傳到AWS S3:

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:pathComp];
    [UIImageJPEGRepresentation(myImage,0.9) writeToFile:filePath atomically:NO];
    filePath = [NSString stringWithFormat:@"file:///private%@", filePath];
    NSURL* fileUrl = [NSURL URLWithString:filePath];
    AWSS3TransferManagerUploadRequest *uploadRequest = [AWSS3TransferManagerUploadRequest new];
    uploadRequest.key = key;
    uploadRequest.body = fileUrl;
    uploadRequest.contentType = @"image/jpeg";

它已正常上傳,但是在機械特克中我無法打開預覽

This page contains the following errors:

error on line 1 at column 1: Document is empty
error on line 1 at column 1: Encoding error
Below is a rendering of the page up to the first error. 

使用NSURL創建文件URL時,應使用+ fileURLWithPath: 您應該更改此行

NSURL* fileUrl = [NSURL URLWithString:filePath];

NSURL* fileUrl = [NSURL fileURLWithPath:filePath];

您應該仔細檢查文件是否已使用AWS管理控制台成功上傳。

另外,默認情況下,所有Amazon S3資源-存儲桶,對象和相關子資源-都是私有的:只有資源所有者(創建該資源的AWS賬戶)才能訪問該資源。 您可以修改ACL來更改權限。

找到PaulTaykalo的適用於AWS開發工具包v2的解決方案

https://github.com/aws/aws-sdk-ios/issues/10

固定方法的鏈接http://pastie.org/9340740

還將這段代碼添加到混亂的方法中

[headers setValue:contentType forKey:@"Content-Type"];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM