android - Android AWS sdk 无法上传
问题描述
我在 MobileHub 上创建了应用程序并集成了 android。配置文件在原始目录中。
打电话后
AWSMobileClient.getInstance().initialize(context).execute();
BasicAWSCredentials credentials = new BasicAWSCredentials(ACCESS_KEY, KEY_SECRET);
AmazonS3Client s3Client = new AmazonS3Client(credentials);
transferUtility = TransferUtility.builder()
.context(context.getApplicationContext())
.awsConfiguration(AWSMobileClient.getInstance().getConfiguration())
.s3Client(s3Client)
.build();
TransferObserver uploadObserver =
transferUtility.upload(
BUCKET_NAME,
file.getName(),
file);
uploadObserver.setTransferListener(new TransferListener() {
@Override
public void onStateChanged(int id, TransferState state) {
System.out.println("State changed:"+state);
}
@Override
public void onProgressChanged(int id, long bytesCurrent, long bytesTotal) {
System.out.println("Progress.."+bytesCurrent);
}
@Override
public void onError(int id, Exception ex) {
System.out.println("error:"+ex);
}
});
我明白了
Welcome to AWS! You are connected successfully.
AWSMobileClient Initialize succeeded.
但是当我尝试上传任何文件(来自公共目录和私有目录)时,它只会触发一次 onProgressChanged,TransferState 为 IN_PROGRESS。没有别的了。
如果无法上传图片,不应该有适当的错误吗?
我的日志猫:
06-12 14:22:41.873 I: Welcome to AWS! You are connected successfully.
06-12 14:22:41.873 D: AWSMobileClient Initialize succeeded.
06-12 14:22:41.873 I: Welcome to AWS! You are connected successfully.
06-12 14:22:41.877 I: registering receiver
06-12 14:22:41.955 I: State changed:IN_PROGRESS
06-12 14:22:41.960 W: finishComposingText on inactive InputConnection
finishComposingText on inactive InputConnection
finishComposingText on inactive InputConnection
06-12 14:22:46.844 V: Inactivity, disconnecting from the service
06-12 14:22:46.845 I: Sending crashes
06-12 14:23:18.221 V: Recording user engagement, ms: 36408
06-12 14:23:18.223 V: Connecting to remote service
06-12 14:23:18.230 V: Activity paused, time: 22740592
06-12 14:23:18.237 D: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=36408, firebase_screen_class(_sc)=AdminActivity, firebase_screen_id(_si)=-1968217097067733732}]
解决方案
推荐阅读
- vba - 在幻灯片母版中命名形状的方法?
- excel - Excel 公式正确但显示 #VALUE 错误
- javascript - Javascript 中 SetInterval 中的 ResponsiveVoice 代码:如何停止循环?
- ios - Apple FFT 给出不一致的结果
- android - 在 GCE 实例上使用 shell 创建 Android 虚拟设备
- amazon-web-services - 重复但临时安排 AWS Lambda
- javascript - 在 Firestore 中使用 Firebase Cloud 功能推送通知
- file - 使用文件名将文件一个文件夹复制到 Google 云端硬盘中的另一个文件夹
- node.js - 多对多自我关联续集
- ruby-on-rails - 使用 ruby 访问浏览器的公共“窗口”属性