AWS S3上传卡在等待状态

我已经查看了有关此问题的几个问题和答案,但是仍然无法上传到S3存储桶。我已经在应用程序标记中的清单中声明了该服务。


每个日志语句都返回正确的信息,但是状态始终为WAITING,并且不会触发任何传输侦听器。我没有收到任何错误,并且S3存储桶仍然为空。


我究竟做错了什么?


public void uploadStoredItems() {


    TransferUtility transferUtility = TransferUtility.builder()

            .context(AWSProvider.getInstance().getContext())

            .awsConfiguration(AWSProvider.getInstance().getConfiguration())

            .s3Client(new AmazonS3Client(AWSProvider.getInstance().getIdentityManager().getCredentialsProvider()))

            .build();


    try {

        for (File csvFile : csvFiles) {

            String filename = csvFile.getName(); //.substring(csvFile.getName().lastIndexOf('/') + 1);

            Log.d(TAG, "This is the filename for upload: " + filename);


            // FileReader reads text files in the default encoding.

            String line = null;

            FileReader fileReader = new FileReader(csvFile);


            // Always wrap FileReader in BufferedReader.

            BufferedReader bufferedReader = new BufferedReader(fileReader);


            while ((line = bufferedReader.readLine()) != null) {

                Log.d(TAG, "Here are the lines: " + line);

            }


            // Always close files.

            bufferedReader.close();


            TransferObserver uploadObserver = transferUtility.upload(filename, csvFile);

            // Gets id of the transfer.

            Log.d(TAG, "This is the bucket: " + uploadObserver.getBucket());

            Log.d(TAG, "This is the state: " + uploadObserver.getState());

            Log.d(TAG, "This is the id: " + uploadObserver.getId());


慕丝7291255
浏览 257回答 1
1回答

LEATH

事实证明,我必须声明TransferUtility服务以与我调用它的服务正在运行的过程相同的方式运行:<application&nbsp; &nbsp; ...&nbsp; &nbsp; <service&nbsp; &nbsp; &nbsp; android:name=".MainService"&nbsp; &nbsp; &nbsp; android:enabled="true"&nbsp; &nbsp; &nbsp; android:process=":main_service"&nbsp; &nbsp; &nbsp; android:stopWithTask="false" />&nbsp; &nbsp; <service&nbsp; &nbsp; &nbsp; android:name="com.amazonaws.mobileconnectors.s3.transferutility.TransferService"&nbsp; &nbsp; &nbsp; android:process=":main_service"&nbsp; &nbsp; &nbsp; android:enabled="true" />&nbsp; &nbsp; ...</application>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java