Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

DownloadFile from Azure Blob Storage #56

Closed
Nazirovich opened this issue Oct 6, 2020 · 1 comment
Closed

DownloadFile from Azure Blob Storage #56

Nazirovich opened this issue Oct 6, 2020 · 1 comment
Labels
On Hold Not working on at this time

Comments

@Nazirovich
Copy link

Nazirovich commented Oct 6, 2020

Describe the bug
I'm trying to download an URL from azure storage, the link is generated with an access signature.

https://--test.blob.core.windows.net/--/message-attachments/3d1b73aa-4818-4d7d-a634-c165ceaf6e69.pdf?sv=2019-02-02&sr=b&sig=AuBDZA2%2B5LZUqtHbI7FOneOM0wKVy2bIUu3v%2BJgXoMA%3D&se=2020-10-06T19%3A06%3A35Z&sp=r

I've tried also the decodeURIComponent version of the URL:

https://--test.blob.core.windows.net/--/message-attachments/3d1b73aa-4818-4d7d-a634-c165ceaf6e69.pdf?sv=2019-02-02&sr=b&sig=AuBDZA2+5LZUqtHbI7FOneOM0wKVy2bIUu3v+JgXoMA=&se=2020-10-06T19:06:35Z&sp=r

The plugin is not working most probably while using "URL url = new URL(urlString);" in the downloadFile function,
it's giving "file not found" because of +/= characters that can be added in the signature.

It's adding number 5 after %2:

Original: AuBDZA2%2B5LZUqtHbI7FOneOM0wKVy2bIUu3v%2BJgXoMA%3D

Becoming: AuBDZA2%252B5LZUqtHbI7FOneOM0wKVy2bIUu3v%252BJgXoMA%253D

This is causing the file not to be found with the correct signature.

The below error found in the Android console:


E/Capacitor/Plugin: Error
    java.io.FileNotFoundException: https://--test.blob.core.windows.net/--/message-attachments/3d1b73aa-4818-4d7d-a634-c165ceaf6e69.pdf?sv=2019-02-02&sr=b&sig=AuBDZA2%252B5LZUqtHbI7FOneOM0wKVy2bIUu3v%252BJgXoMA%253D&se=2020-10-06T19%253A06%253A35Z&sp=r
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:255)
        at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:211)
        at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:30)
        at com.getcapacitor.plugin.http.Http.downloadFile(Http.java:167)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99)
        at com.getcapacitor.Bridge$1.run(Bridge.java:526)
        at android.os.Handler.handleCallback(Handler.java:888)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:213)
        at android.os.HandlerThread.run(HandlerThread.java:67)

--

Expected behavior
The URL should be working even with these characters

Screenshots
Screen Shot 2020-10-06 at 10 07 26 PM

@thomasvidas
Copy link
Contributor

This is due to the way we sanitize URL inputs. The % is encoded to %25. Either way, I will put this on hold while I figure out the best way to address this since we don't want to break existing projects.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
On Hold Not working on at this time
Projects
None yet
Development

No branches or pull requests

2 participants