How to request storage permission in android 10 and above versions in android? - android-permissions

Can anyone tell how to ask user to give storage permission in android 10 and above versions. Please guide me in this regard I have used various methods but they did not worked!!!

If you want to write any file in the External storage, then you must have WRITE_EXTERNAL_STORAGE permission in your app below android 10.
In android 10, you can use requestLegacyExternalStorage=true in the application tag in your manifest. It will provide you the access to write file anywhere in External storage.
But it's a temporary solution as it'll be removed in the future. So the best solution is using SAF (Storage Access Framework) or Scoped Storeage.
SAF : It's an Android framework to secure user's files and help developers in managing files. However, different API levels require different approaches to manage and access files. Higher API level means more restrictions given to developers.
Scoped Storage : After you update your app to target Android 11, the system ignores the requestLegacyExternalStorage flag. So you must use Scoped storage or SAF to write any file into the storage.
With scoped storage, you can't write any files in the External storage in android 11 even If you have Write storage permission. It will be ignored. You can write your files in app's internal storage or in the Media directory related to the file you're writing.
For example, if you are going to write an Image, then you must write it in DCIM directory, For Videos - Movies, For Document - Documents, and so on.
The best part about scoped storage is that you don't need write storage permission in Android 10 & above and you can still write the files in their respected directories. If you're writing the image & your custom directory is not created in the storage, then android will automatically create it while writing the file. You don't have to do file.mkdir().
But if you want to write any file in the out of your app's scope, then you have to clarify why you need to do that while releasing the apk on Playstore.
And only File operations related apps can get that approval because most of apps do not need to write files out of their scope in the External storage.
So if you are writing files in android 10 or above, then simply don't request write permission, request only read storage permission if you're using Scoped storage or SAF.

Related

A method for linking a server side file to a Squarespace page?

I'm trying to build a website on Squarespace, in which the site links to a database file. It's stored in a standard file system on a server tower with cluster. No SQL architecture or anything that I explicitly know of. Unfortunately Google Drive isn't an option due to the size of the file ( > 200 GB). I'm rather lost due to the size constraint -- does anyone have an idea about how to do this? Can I set up some sort of server query using a link on the site? Can I upload the file from my computer and store it somewhere in the backend? Thanks.
"...the size of the file ( > 200 GB)..."
Unfortunately, Squarespace's own upload limitations are far below this for the two places where files like that can be stored: file storage (20MB) and developer-mode '/assets' folder (10MB). The CSS-/Style-related storage only supports images (and likely has a limit of less than 20MB). Digital download products can be 300MB (still to small for your file) and likely can't be linked-to and accessed as you'd need for your application.
"...Can I set up some sort of server query using a link on the site?..."
If you mean a query on some other service besides Squarespace which connects to the file hosted on your Squarespace site, the answer is no simply because there's no way to upload the file to Squarespace due to its size. If, however, your mean a query from your Squarespace site to the file hosted elsewhere, then this must be done using JavaScript and done entirely client-side due to Squarespace's lack of support for server-side languages.
"...Can I upload the file from my computer and store it somewhere in the backend?..."
See the options mentioned above, though all have file size limits below that of your file.
If you are able to utilize the file on your site using client-size/front-end JavaScript only, then perhaps you could host the file on Amazon S3 or other such provider and access it that way.

Where to store File/Images in Wildfly server?

I am using Wildfly 9.0.2.Final, while in development, all my files that uploaded via my web service and stored in resources/images are gone when I perform a full-publish (luckily this are development dummy images). In production, where is the best place to store or best practice to prevent files/images from missing?
If the files belong somehow to your application, place the somewhere inside the web application (and outside of WEB-INF). They will be accessible through the respective URL path.
If your application needs to store user data that gets uploaded dynamically during application runtime and shall persist even if you redeploy the application, then you better have a configurable directory on disk. One default option to find the JBoss/Wildfly data directory could be to query for the system property 'jboss.server.data.dir'.

Can I use Google Cloud Storage for Apache DocumentRoot?

I was reading the docs and saw the following:
Standard Storage is appropriate for storing data that requires low latency access or data that is frequently accessed ("hot" objects), such as serving website content, interactive workloads, or data supporting mobile and gaming applications.
With that said, I wanted to know how would I go about mounting a gs://bucket? I would prefer to go this route than to create an NFS/GlusterFS.
You can use gcsfuse to mount a Google Cloud Storage bucket as a filesystem that Apache can read:
gcsfuse is a user-space file system for interacting with Google Cloud Storage.
As of 20 August 2015, the project's README also says:
Current status
Please treat gcsfuse as beta-quality software. Use it for whatever you like, but be aware that bugs may lurk, and that we reserve the right to make small backwards-incompatible changes.
The careful user should be sure to read semantics.md for information on how gcsfuse maps file system operations to GCS operations, and especially on surprising behaviors. The list of open issues may also be of interest.

Continuous sync of dropbox files to third party app

I am looking for dropbox apis which will serve me to sync all/specific files into third party app. I have explored core API and Sync API but couldn't figure out right strategy to implement this scenario.
Use case details :
user grants dropbox permission/connects to my app.
User share set of existing files to app.
If there is any changes happened to the set of files shared with app, i should able to identify them without downloading the files again.
I have come across some applications(ex: zohodocs) which continuously sync files from dropbox to their application. Are they continuously check all files in the dropbox user account to find the changes. What is the effective way to doing this.
Also please suggest appropriate API's without violating user security by granting more than required permissions.
The answers depends on what kind of app you're building and where it runs.
For client-side apps (JavaScript in the browser, mobile apps, desktop apps), you should be using a combination of /longpoll_delta and /delta to find out when files change and then what the specific changes were.
For server-side apps where you're monitoring a lot of user accounts at the same time, you should be using webhooks to get a notification when files change in a user's Dropbox, and then /delta to get the specific changes.
In terms of permissions, the options are here: https://www.dropbox.com/developers/reference/devguide#app-permissions. Without knowing the specifics of the app, it's hard to tell you which permissions you'll need to use.
EDIT
I should add that, in the case of a client app, the Sync API automates the /longpoll_delta-/delta loop. You instead just add listeners/observers to get notified when files change.
We have the same use-case and poll dropbox every 15 minutes by calling the /delta service
https://www.dropbox.com/developers/core/docs#delta
This is very efficient. We are using our own library for this, https://github.com/rmuller/dropbox-java-client.

Wireless updating in objective-c

I have an application in the store that has a bunch of UITableViews, each has a bunch of items that when selected, load a UIWebView that loads a local HTML file. The reason I do this is so it allows for viewing when there is no internet access, however it makes it tedious to update.
How would I go about both keeping local files, and keeping web files, so that If I update one on the web it would let the user know there is an 'update' and it can download and overwrite the old file with the new. Is this possible? Like I would make myself a backend to edit my HTML, and have a connection to the app so whenever I clicked save the app would know to ask the user to update the files so I don't have to submit to apple for such small updates.
But I still need to allow offline viewing in case they didn't have internet access.
What technologies or techniques would I have to research to accomplish this?
Thanks
what you're looking for is an html5 concept called application cache.. it directly addresses your problem. With app cache you can cache static content at the client side, which they can view even if they're offline, yet they can update it when the content on the server changes. If you look around you'll see people use this for the iPhone as well.
update:
What way would I go about rewriting files on the phone from ones on a server?
you basically update the cache to do that. from the docs:
The application cache automatically updates only if the manifest file
changes. It does not automatically update if resources listed in the
manifest file change. The manifest file is considered unchanged if it
is byte-for-byte the same; therefore, changing the modification date
of a manifest file also does not trigger an update. If this is not
sufficient for your application, you can update the application cache
explicitly using JavaScript.
I encourage you to do some reading on html5 local storage just to get the concept of local cache and manifest files etc, then just follow through the instructions on the apple docs.. It's not that difficult.
You can cache the content as abbood said but that won't allow you to provide initial offline content.
Another approach would be to use NSURLProtocol, which allows you to swizzle a request. For example, if you have a request for "http://google.com", you would be able to either change the URL or load your own content (say from a local directory).