Android 11 Storage Access Framework - How to use files? - storage-access-framework

Hey there fellow devs,
I have come across a problem while migrating our app to the new API 30 standards with the storage access framework (SAF).
I have successfully migrated the file structure and am now using the internal (FilesDir) paths.
Getting images with the MediaStore-Api is also working quite nicely.
But there is one big issue I just can't seem to fix.
In our app, we are using the API "Mapsforge" for Offline-Maps.
This API is using a Java.IO.File-Object we get from a path to a ".map" file which is almost 2GB large.
This file does not come from us, it is a file managed by the customer and put onto the device for us to use, since all the ".Map"-Files are custom.
Since the SAF is returning an Android.Net.Uri, I can't seem to convert it to a Java.IO.File without copying the contents of the file and therefore using even more storage on the device.
Is there any way to use the SAF to get a Java.IO.File-Object I can use in code?
If not, then Android 11 is making it very hard for my Customer to manage his storage.

This API is using a Java.IO.File-Object we get from a path to a ".map" file which is almost 2GB large.
With luck, Mapsforge will offer more flexible APIs in the future. You may wish to contact them about their recommendations.
Is there any way to use the SAF to get a Java.IO.File-Object I can use in code?
No. After all, the user might choose something on Google Drive or another cloud storage provider, rather than a local file. Or, they might choose a file that is inaccessible to your app. Or, they might choose content that is stored in an encrypted file, which needs to be decrypted by the document provider. And so on.

Related

Looking for an incremental upload solution (changes only) on iOS

Is there a high-level platform solution for iOS for providing 'changes only' upload to a file. I am currently building app that is using a realm database and this realm file is written to all the time throughout the app's life-cycle. I don't want to upload a 3MB database every time there is a small change to database.
Is there a service that provides solution for my problem? I am not sure if Google Drive/Dropbox API provide a solution for this. Would love to get a lowdown on this from people who have faced this issue or used Google drive/Dropbox API.
You can use the Google Spreadsheet API to make incremental changes/additions to a spreadsheet.

Sharing a Realm Database between a user's devices

Is there a formal way for a Realm Database to be shared between a users iPhone and iPad? Clearly that will need some kind of server that a database can be pushed and pulled from. Is there a solution for this, like is there a way to use iCloud?
If not does anyone one have any ideas for a path of least resistance for implementing this myself?
Found this chat on the Realm's GitHub page
https://github.com/realm/realm-cocoa/issues/913
I am still hoping someone here has got around this issue?
Realm hasn't provided sync feature yet. We are actively working on sync building feature, but we don't have no ETA at the moment.
Easy ways are sharing Realm data file with iCloud or other services. e.g. DropBox API.
https://www.dropbox.com/developers
Or this library might help you...? https://github.com/BellAppLab/RealmCloudKit
Second, using serverside database to sync with local database. Like Parse.com.
https://parse.com/

Uploading pdf files stored in iphone to server in ios

I am making an iphone application which is pretty much like forum. People can ask question and upload a pdf/doc file along with the question. Is there a way to access the pdf/doc file in iphone when user clicks upload button and send the file to server?
I have implemented the feature for image for which I used UIImagePicker to pick the image and send it to the server with http request. But I am completely lost and have no idea how to handle pdf/doc files in same manner.
Any help/suggestion really appreciated. Thanks in advance.
If you want to upload PDF and Doc files, then you can integrate Dropbox and Google Drive in your app and then select the files ,as Apple does not have centralised storage. If you notice Apple also chooses the documents from Google Drive while composing a mail.
So implementing and integrating google drive and Dropbox would be a good option.
Here is the link for Dropbox https://www.dropbox.com/developers-v1/core/sdks/ios
Here is the link for Google Drive https://developers.google.com/drive/ios/quickstart
Implementing Google drive is a bit hard but dropbox is quite simple.
Wish it saves your time. All the best!
I think you are looking for a combination of two things (both have been discussed here before and I include the links below).
(1) store a PDF. There are many options but the best way is to allow coredata to save outside the persistent store. Then store the reference to the file in core date. See: Insert a PDF file into Core Data?
(2) send the file to the server. There are many options for this as well. The fastest is probably to use a wrapper library such as ASIHTTPRequest. See: File Upload to HTTP server in iphone programming

Google Drive as a video hosting/streaming platform?

I'm developing an iOS app that generate video files and have a social gallery for users to display their clips. After a lot of research I found that Google Drive would be perfect to fit my needs so I did some testing and sucessfully made the app upload the file to GDrive and everything.
Now I need to stream the uploaded file in a MPMoviePlayerViewController, for that I would need some kind of direct link, I'm right? After my initial tests I used the variable WebContentLink as a source URL and it worked flawlessly, I was really happy with the result, however now it doesn't work anymore, I don't know what happened and I think the method that I used is not realiable? I tried all the other possible links and none of them seems to work.
Can someone give a guidance about if this is really supported by Google Drive and how it's the best way to archive that in a reliable way?
Thank you very much !
I too encounter the same error when I try to download 28 times (testing) the same 24mb file.
However I realise if I am to download using the content owner ID, it does allow downloading after the 28th time
https://docs.google.com/a/onwardsct.com/uc?id=0ByvXJAlpPqQPYWNqY0V3MGs0Ujg&export=download
Sorry, you can't view or download this file at this time.
Too many users have viewed or downloaded this file recently. Please try accessing the file again later. If the file you are trying to access is particularly large or is shared with many people, it may take up to 24 hours to be able to view or download the file. If you still can't access a file after 24 hours, contact your domain administrator.
The experience for streaming files natively is not ideal right now, sorry. It is something Google are working on.
You are doing this correctly though. The webContentLink should use the user's quota, and that should be enough for most cases. If you can give some specific numbers, we can look at it.
The embed link is the best way to show it on a mobile device, but as you say won't work everywhere.
yes, google drive can be used for hosting and stream videos as you like. It can also be used as demo server for web projects. Here is how to host a website on Google drive.

iPad app designing: sync with Excel file

I'm designing a new app for iPad for a small company. This app will use Core Data to store a local database and a database of products and prices. The last database needs to be always up to date since the prices can change.
This company, has a Excel file to keep this database of prices. So they don't have a SQL db to which I can interact from my app.
One option could be to export the Excel file in CVS and put that file in their server (accessible by internet). Then my app should parse the file.
I don't like very much this idea, though.
Do you have any suggestion?
I had a very similar problem to you. I recently got into a project where the client wanted to import information from an Excel file into an app. I know a lot of people say, just transform it into a CSV and parse it that way, but I really didn't want the client to go through yet another step and introduce a different file format - as simple as that may be.
I also really don't like having the information in the cloud, especially Google. Privacy is something that's important to most companies and I'd doubt they'd approve of you using Google to parse the info.
In order to parse the file, I created QZXLSReader. It's a drag-and-drop solution so it's a lot easier to use. I don't think it's as feature complete, but it worked for me.
It's basically a library that can open XLS files and parse them into Obj-C classes. Once you have the classes, it's very easy to send them to Core Data or a dictionary or what have you.
I hope it helps!
Here are a couple of options for you:
Use Google Doc as the intermediary. When the pricing Excel is updated by someone, simply upload the updated Excel to Google Docs. From your iPad app, you can read the latest data via the Goole API. If the company is up for it, they can move to Google Doc altogether and just modify the online Google Spreadsheet directly.
Use services like StackMob as the intermediary. You will have to write a tool to sync the pricing Excel with SrackMob but you can easily access the data via StackMob's iOS SDK.

Resources