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
Add Blob downloading feature (Android) #3022
base: master
Are you sure you want to change the base?
Add Blob downloading feature (Android) #3022
Conversation
I tried branch code of blob-download-feature in react-native-webview repo, when download blob, it shows error I hope this issue can be fixed in blob-download-feature PR. |
Hi @WANG-Lisa, thanks for reporting this, Also if you can provide a repo with the project you have faced the issue with, that would be helpful, Thanks. |
@devmuhnnad Thanks for your quick response.
I test it on android simulator, here is the info of simulator
|
Hi @WANG-Lisa, I see that you are using the source prop wrong! |
My fault to this misunderstanding. Actually my case is what you indicate. I load an https page in webview, then in this https page, I want to download a pdf which type is blob. Once I click the download button, it shows Content Security Policy error. |
@WANG-Lisa it would help if you share with me a repo of your project |
As the repo is confidential, I can't share it out. However, I find that if the blob is of type pdf or csv, it will show the error I indicate, others like 'application/json', it's ok to download. |
@WANG-Lisa I understand. |
I'll try to reintegrate after this PR is merged. Looking forward to this feature to be released asap. |
Hi @devmuhnnad, can you help me? I tried to install from this PR with yarn: |
android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java
Outdated
Show resolved
Hide resolved
android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java
Outdated
Show resolved
Hide resolved
android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java
Outdated
Show resolved
Hide resolved
android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java
Outdated
Show resolved
Hide resolved
req.send(); | ||
|
||
function sendMessage(message) { | ||
ReactNativeWebViewDownloader.downloadFile(JSON.stringify(message)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReactNativeWebViewDownloader.downloadFile(JSON.stringify(message)); | |
ReactNativeWebViewDownloader.downloadFile(JSON.stringify(message)); |
const popularExts = ["pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt", "jpg", "jpeg", "png", "gif", "bmp", "tiff", "tif", "svg", "mp3", "mp4", "avi", "mov", "wmv", "flv", "ogg", "webm", "mkv", "zip", "rar", "7z", "tar", "gz", "bz2", "iso", "dmg", "exe", "apk", "torrent", "epub", "mobi", "azw", "azw3", "djvu", "djv", "fb2", "rtf", "odt", "odp", "ods", "odg", "odf", "odb", "csv", "tsv", "ics", "vcf", "msg", "eml", "emlx", "mht", "mhtml", "xps", "oxps", "ps", "rtfd", "key", "numbers", "pages", "apk", "torrent", "epub", "mobi", "azw", "azw3", "djvu", "djv", "fb2", "rtf", "odt", "odp", "ods", "odg", "odf", "odb", "csv", "tsv", "ics", "vcf", "msg", "eml", "emlx", "mht", "mhtml", "xps", "oxps", "ps", "rtfd", "key", "numbers", "pages"]; | ||
let ext = blob.type.split("/")[1]; | ||
if (!ext || !popularExts.includes(ext)) { | ||
ext = "bin"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ext = "bin"; | |
ext = "bin"; |
}); | ||
|
||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}; | |
}; |
Hello 👋, this PR has been opened for more than 2 months with no activity on it. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically |
@devmuhnnad Could you please take a look :) ? |
…iew.java Co-authored-by: Caleb Clarke <TheAlmightyBob@users.noreply.github.com>
…iewManagerImpl.kt Co-authored-by: Caleb Clarke <TheAlmightyBob@users.noreply.github.com>
Hi, sorry for the delay, |
@TheAlmightyBob Could you please take a look :) ? |
Why would it be a Android only feature ? Can't it be done for iOS also ? |
Hello. |
@devmuhnnad Please make it for IOS |
Go to the file and replace it by
|
@jamonholmgren @Titozzz can this PR be merged? |
I've a blob (audio/wav) and I'll have to save/download the blob as a .wav file. @devmuhnnad you mentioned we should pass a valid URL that starts with "http" or "https". Does this mean that I'll not be able to use this patch to save my blob as a wav file? |
@ainnotate When you create blob url it auto add HTTP to it, see #2858 (comment)
|
With this will I be able to use: URL.createObjectURL(blob) ? |
Hello people, when is this pr going to be merge? I have the same problem. Help please. |
any progress? |
This fixes #2951, #2526, #2207, #1945, #1790, #909, #295 and #2526
I have tested the feature on a React native project, and it worked perfectly 🌟
Usage
For security purposes, the Blob Downloading Feature is not enabled by default,
blobDownloadingEnabled
prop is used.Is this a Breaking Change
No, I have developed this feature to be independent, not affecting others.
THANKS.
PART OF GTC OPEN SOURCE INTIATIVE