我要做的是将图片上传到我的AWS。
当我点击发送按钮时,'uploadData'方法激活。
我想我在createUserFileManager或uploadContent中的参数有问题或我的授权过程......我不确定。
请帮帮我。
这是我的uploadData方法。
public void uploadData(String path) {
final String filepath=path;
AWSMobileClient.initializeMobileClientIfNecessary(this);
AWSMobileClient.defaultMobileClient()
.createUserFileManager(AMAZON_S3_USER_FILES_BUCKET, null ,AMAZON_S3_USER_FILES_BUCKET_REGION, new UserFileManager.BuilderResultHandler() {
@Override
public void onComplete(final UserFileManager userFileManager) {
File file = new File(filepath);
userFileManager.uploadContent(file,"/public/new folder/" + file.getName(), new ContentProgressListener() {
@Override
public void onSuccess(final ContentItem contentItem) {
Log.d(LOG_TAG, filepath);
finish();
// Handle successful action here
}
@Override
public void onProgressUpdate(final String fileName, final boolean isWaiting,
final long bytesCurrent, final long bytesTotal) {
}
@Override
public void onError(final String fileName, final Exception ex) {
Log.d(LOG_TAG, "upload failed");
// Handle error case here
}
});
}
});
}
这是我的logcat。
10-07 18:22:23.804 32219-32219/com.example.idolschool D/AWSMobileClient: AWS Mobile Client is OK
10-07 18:22:23.844 32219-32219/com.example.idolschool D/TransferSerivce: Starting Transfer Service
10-07 18:22:23.854 32219-32219/com.example.idolschool D/TransferSerivce: Network connected: true
10-07 18:22:23.854 32219-14188/com.example.idolschool D/TransferSerivce: Loading transfers from database
10-07 18:22:23.854 32219-14188/com.example.idolschool D/TransferSerivce: 0 transfers are loaded from database
10-07 18:22:23.884 32219-14189/com.example.idolschool I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
10-07 18:22:23.884 32219-14189/com.example.idolschool I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
10-07 18:22:25.154 32219-14189/com.example.idolschool I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
10-07 18:22:25.154 32219-14189/com.example.idolschool I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
10-07 18:22:25.784 32219-14189/com.example.idolschool I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
10-07 18:22:25.784 32219-14189/com.example.idolschool I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
10-07 18:22:26.474 32219-14189/com.example.idolschool I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
10-07 18:22:26.474 32219-14189/com.example.idolschool I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
10-07 18:22:26.904 32219-14189/com.example.idolschool E/UploadTask: Failed to upload: 20 due to Unable to execute HTTP request: Write error: ssl=0x7f94269100: I/O error during system call, Connection reset by peer
10-07 18:22:26.904 32219-32219/com.example.idolschool D/Application: upload failed
10-07 18:23:23.914 32219-14188/com.example.idolschool D/TransferSerivce: Stop self
感谢您阅读我的问题! 任何解决我的问题的代码请求将不胜感激!
答案 0 :(得分:0)
我通过调整我的IAM配置和createUserFileManager的参数解决了这个问题,该参数已经为null,为“public /”