Skip to content
This repository has been archived by the owner on Mar 16, 2019. It is now read-only.

Android, download a apk form S3, but get a bin #391

Open
Charles-LMQ opened this issue Jun 6, 2017 · 4 comments
Open

Android, download a apk form S3, but get a bin #391

Charles-LMQ opened this issue Jun 6, 2017 · 4 comments

Comments

@Charles-LMQ
Copy link

Charles-LMQ commented Jun 6, 2017

Hi, I am using

 RNFetchBlob.config({
               addAndroidDownloads : {
                  useDownloadManager : true, 
                  notification : true,
                  mediaScannable : true,
                  mime : 'application/vnd.android.package-archive',
                  description :  '  downloaded by download manager.'
              }
            }).fetch('GET', gotURL)

            .then((res) => {
              // the conversion is done in native code
              console.log('The file saved to ', res.path());
               let sendIntent = RNFetchBlob.android.actionViewIntent;
               sendIntent(res.path(), 'application/vnd.android.package-archive');
            })
            // Status code is not 200
            .catch((errorMessage, statusCode) => {
              // error handling
            })

and download can be processed, but I do not why it is always get a file called 'downloadfile.bin', my file is on the AWS S3, it seems cannot fetch the correct file name from S3 Pre-signedURL?

Please.

@wkh237
Copy link
Owner

wkh237 commented Jun 7, 2017

@Charles-LMQ , does the .bin file contains correct content ?

@Charles-LMQ
Copy link
Author

@wkh237 yeah, it has correct content.

@Charles-LMQ
Copy link
Author

@wkh237 hi, dude, I think I find the problem, in the RNFetchBlobReq line 152 around

You missed

            if(options.addAndroidDownloads.hasKey("mime")) {
                req.setMimeType(options.addAndroidDownloads.getString("mime"));
            }

            if(options.addAndroidDownloads.hasKey("mediaScannable") && options.addAndroidDownloads.hasKey("mediaScannable") == true ) {
                req.allowScanningByMediaScanner();
            }

And around line 650

                filePath = contentUri;

                if (options.addAndroidDownloads.hasKey("mime") && options.addAndroidDownloads.getString("mime").equals("images something") && contentUri != null) 

about 650, you miss check if some times the mime may not be a images.

After all this, the code will be fine to fully support the apk download without exceptions.

BTW, it is a great plugin as awesome!!

Thx.

@wkh237 wkh237 added the android label Jul 4, 2017
@wkh237
Copy link
Owner

wkh237 commented Jul 4, 2017

@Charles-LMQ , great thanks for pointing out this, will fix this in next release. It's also welcome to make a PR 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants