I'd like to generate a signed link via S3 and then allow a mobile user to download this file. So far this is going okay (downloads with the correct name, filesize, etc).
However - when it comes to opening it (even a .png), I get the message "Cannot open file" and it doesn't turn up in the device's photos, gallery, or anything like that.
Are there some kind of headers missing? Some extra bit of set-up?
The context is a React Native app where the user requests a file, opens the URL via Linking in Chrome, Chrome downloads it, and then they can open it properly. Ideally this will work for any file types (e.g. png, jpg, docx, pdf). Thanks!
If you can't do this in ReactNative, you can always leverage on a native picker. https://developer.android.com/guide/topics/providers/document-provider in any case, there are tons of information to open files in ReactNative with some extensions as: https://github.com/huangzuizui/react-native-file-opener. I tried a couple of them and they work. It should do the job, check the permissions in your application as well. It can be a headers problem so you need to check all of this.
Related
We have a file server on which we place PDF documents and then embed links to them in a smart device app. Up until recently, using links to the PDF documents starting with http:// worked fine for Android and iPhone users. All could load the PDF file just fine. Then a few months back (approximately) Android phone users started reporting they would get an error when trying to load any PDF. Yet iPhone users had no issues loading the same PDF document. It was verified that these PDF documents (several) were not corrupted and opened fine when placed on another file server.
I have an iPhone so I can't give you the exact error msg received by Android users but to reproduce it, it was along the lines of... click the link to the PDF, a button appears showing View PDF, click that button and several apps appear to choose the app to open the PDF with, click one (like Adobe Reader, or Google Drive) and an error appears stating the file could not be opened and may be corrupted of the wrong syntax.
Tonight I found the solution.
The url to the PDF on all these documents on our server had been like http://...
but when I changed it to https://... it works fine.
I can't find ANYWHERE any mention of a change by Google that this is now a requirement.
My question...
Can someone explain and/or point me to a reference that explains why https must be used in embedded links to PDF documents? It seems like a pretty big deal to make this a requirement and not tell anyone. My searching the internet has so far not turned up anything.
I have been able to successfully create a TWA from the base instructions provided. It links to the website and works as expected.
However, one of the functionalities of the web app is to upload a particular file type (which is a type of zip) and display its content. That functionality too works as expected and one is able to upload the file, say from the downloads directory to the app and it displays.
What would be desirable is: for the user to tap on the file from the directory (say downloads) and it opens in the App. I am aware of the limitations of access a local file in any web app. But before I tackle that issue I would like to know if there is a way to associate that file extension (or mime-type) with the app. And more importantly how to at least get the path of the file. In the current setup there is no custom Activity java code written. I went by the documentation and put the right settings in the manifest.xml and the site gets loaded.
Thanks.
This is possible by implementing Web Share Target in your Progressive Web App, then enabling it in our Trusted Web Activity.
When using Bubblewrap it will to automatically configure the Trusted Web Activity on init.
We are working on an android app that generates PDFs based on app contents on users' request. We are providing an option to launch an email agent and attach the generate PDF, but we also want the user be able to view the document later at any time. On android, there are no stock file explorer, so our first thought was to show on the stock Downloads app's file list. We've tried the following two methods but without luck.
We firstly tried to save the PDF to the default download folder (given by calling Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS)) and invoke media scanner, but the file doesn't show up in the Downloads app's list. It's shown in Adobe Acrobat's local document list though.
After some research, it seems that the Downloads app would only show files that downloaded though DownloadManager, so we tried to generate the PDF in a temporary directory and call DownloadManager to download it, but, somehow expected, it complains that we can only download via HTTP(S), so this approach isn't working as well.
Is there any other solution?
well if you have to provide access to the document without any file explorer app, i think your approach is correct it to allow to store it in the Download lists. To achive this you can use Nanohttpd in your application to host your pdf document and then invoke the DownloadManager download action using HTTP(S) to your webapp (you will have to create a small webapp to handle the download request) hosted on localhost server.
I try to load an image file from the phone. And by using the example code (Camera.sourceType = Camera.PictureSourceType.PHOTOLIBRARY), when a button is pressed, a popup showing that I can select to open "Photo Library" OR "File Manager" (some names like that, may differ across phone models and languages). I can get the returned image file if I select it via Photo Library (as the code indicated?), but failed if I use "File Manager". The error is saying "Unable to load local resources - file://....". (In contrast, the returned value from Photo Library is of the content:// protocol).
Since users may randomly use one of the applications (and some images are not in photo library scope), how can I get it correct with both ways?
=======Update========
Just realize that the error is reported because I use the returned file handle to the image as the image source. And my phonegap app use a remote link as index.html, which is thus not allowed to load local resources (cross-domain issue).
So I need to upload it at background firstly and set the image source to the returned url instead...
Just as I updated, I use a remote page (e.g., http://domain.com/index.html) instead of a page in assets (e.g., index.html, in most PhoneGap documents and tutorials). So the file:// protocol will meet cross-domain restrictions and cannot be loaded by the remote page. While the content:// protocol has no such restrictions. I have to reorganize the architecture of my solution.
Am looking for the way to play video inside my android browser locally. There may be two or more video's in a local page (like facebook contains video's).
Can anyone please help me out..
Without actually reading about the specifics of the Android built in browser I would safely say, you can't. Well, if you run a local html file it might work, but if you intend to have an external page from which you can play local videos it shouldn't work. I say shouldn't because in the early days of browsers some of them actually did give you access to the local file system. Javascript for example could use file://, something I used myself for image previewing before upload. But this was a major security concern and all modern browsers prevent this.
The difference is if you run a local file or a file on your own local web server. Since then, your local file system is actually part of the web servers file system and the web server can serve your local files.