Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TransferUtility does not update the TransferListener when the preferred network type is not available #958

Closed
GerardoRobledo opened this issue May 15, 2019 · 2 comments
Assignees
Labels
bug Something isn't working pending-release Code has been merged but pending release s3 Issues with the AWS Android SDK for Simple Storage Service (S3).

Comments

@GerardoRobledo
Copy link

GerardoRobledo commented May 15, 2019

Describe the bug
When using the following method public TransferObserver upload(String bucket, String key, File file, ObjectMetadata metadata, CannedAccessControlList cannedAcl, TransferListener listener) in airplane mode, TransferStatusUpdater won't notify any listener because is not added by the time TransferRecord.checkPreferredNetworkAvailability has been called.

To Reproduce
A code sample or steps:

 val observer = transferUtility.upload(Constants.BUCKET_NAME, fileToUpload.name, fileToUpload,
                    ObjectMetadata(),null,transferListener)

Which AWS service(s) are affected?
S3

Expected behavior
Debugging TransferUtility class you can see the following.

    public TransferObserver upload(String bucket, String key, File file, ObjectMetadata metadata,
            CannedAccessControlList cannedAcl, TransferListener listener) {
        if (file == null || file.isDirectory() || !file.exists()) {
            throw new IllegalArgumentException("Invalid file: " + file);
        }
        int recordId;
        if (shouldUploadInMultipart(file)) {
            recordId = createMultipartUploadRecords(bucket, key, file, metadata, cannedAcl);
        } else {

            final Uri uri = dbUtil.insertSingleTransferRecord(TransferType.UPLOAD, bucket, key, file, metadata,
                    cannedAcl, transferUtilityOptions);
            recordId = Integer.parseInt(uri.getLastPathSegment());
        }
        //this line triggers TransferRecord
       submitTransferJob(TRANSFER_ADD, recordId); 
       // this initialize our TransferObserver.
        return new TransferObserver(recordId, dbUtil, bucket, key, file, listener); 
    }

If we change to

    public TransferObserver upload(String bucket, String key, File file, ObjectMetadata metadata,
            CannedAccessControlList cannedAcl, TransferListener listener) {
        if (file == null || file.isDirectory() || !file.exists()) {
            throw new IllegalArgumentException("Invalid file: " + file);
        }
        int recordId;
        if (shouldUploadInMultipart(file)) {
            recordId = createMultipartUploadRecords(bucket, key, file, metadata, cannedAcl);
        } else {

            final Uri uri = dbUtil.insertSingleTransferRecord(TransferType.UPLOAD, bucket, key, file, metadata,
                    cannedAcl, transferUtilityOptions);
            recordId = Integer.parseInt(uri.getLastPathSegment());
        }
        TransferObserver transferObserver = new TransferObserver(recordId, dbUtil, bucket, key, file, listener)
        submitTransferJob(TRANSFER_ADD, recordId); 
       
        return transferObserver; 
    }

then the listener would be called.

Screenshots
Screen Shot 2019-05-14 at 7 06 18 PM
Screen Shot 2019-05-14 at 7 07 35 PM

Screen Shot 2019-05-14 at 7 08 48 PM

@mutablealligator mutablealligator self-assigned this May 15, 2019
@mutablealligator mutablealligator added s3 Issues with the AWS Android SDK for Simple Storage Service (S3). bug Something isn't working Investigating labels May 15, 2019
@mutablealligator
Copy link
Contributor

@GerardoRobledo Thank you for the detailed analysis. I have submitted PR #961 to fix the issue. I will update this thread when the fix is released.

@mutablealligator mutablealligator added pending-release Code has been merged but pending release and removed Investigating labels May 16, 2019
@mutablealligator mutablealligator changed the title S3 Missing TransferUtility state in airplane mode TransferUtility does not update the TransferListener when the preferred network type is not available May 16, 2019
@mutablealligator mutablealligator changed the title TransferUtility does not update the TransferListener when the preferred network type is not available TransferUtility does not update the TransferListener when the preferred network type is not available May 16, 2019
@mutablealligator
Copy link
Contributor

This has been fixed in 2.13.5 version of the SDK. closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending-release Code has been merged but pending release s3 Issues with the AWS Android SDK for Simple Storage Service (S3).
Projects
None yet
Development

No branches or pull requests

2 participants