gpt4 book ai didi

java - Transferutility 传输失败 s3

转载 作者:太空宇宙 更新时间:2023-11-04 13:25:43 25 4
gpt4 key购买 nike

我正在尝试从 s3 存储桶下载文件,但我不断收到非法状态异常,并显示消息“传输失败”。上传效果很好。这是我的代码和堆栈跟踪。有人知道可能出了什么问题吗? (最后一点,image.url 不是一个完整的 url,它是一个 objectKey)

File parent = new File(getFilesDir() + "/images");
parent.mkdirs();
File file = new File(getFilesDir() + "/images/" + image.url);
File thumbFile = new File(getFilesDir() + "/images/" + image.thumbUrl);

System.out.println("File path: " + file.getPath());
System.out.println("Thumbnail path: " + thumbFile.getPath());

TransferObserver observer = transferUtility.download(
BUCKET_NAME, /* The bucket to download from */
image.url, /* The key for the object to download */
file /* The file to download the object to */
);
observer.setTransferListener(downloadListener);

Download with id 313 encountered an error: Transfer failed. java.lang.IllegalStateException: Transfer failed. at com.amazonaws.mobileconnectors.s3.transferutility.TransferObserver$TransferContentObserver.onChange(TransferObserver.java:219) at android.database.ContentObserver.onChange(ContentObserver.java:129) at android.database.ContentObserver$NotificationRunnable.run(ContentObserver.java:180) at android.os.Handler.handleCallback(Handler.java:730) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:5419) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) at dalvik.system.NativeStart.main(Native Method)

最佳答案

我自己解决了。我认为授予“每个人”对我的存储桶的读取权限就足够了。实际上,我必须设置一个存储桶策略,以使上传的每个文件也获得这些设置。我使用了这个策略:

{ "版本":"2012-10-17", “陈述”:[ { "Sid":"添加权限", "效果":"允许", "校长": "", "操作":["s3:GetObject"], "资源":["arn:aws:s3:::examplebucket/"] } ]}

关于java - Transferutility 传输失败 s3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32684649/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com