How to add option in setting to pick a directory for downloads in ionic 6 - file-transfer

Is there any way, a user can select the folder where he wants to store downloaded files from the app. I am searching all over the internet and found cordova-plugin-chooser but I don't see any way to select the directory mentioned in the document.
I want to add functionality just like IDM has. User can select any folder in settings where he wants to store files. If there is any library, please let me know. Thanks

Related

How do you create files in arbitrary locations using Swift?

How do you go about creating files at arbitrary locations given you have the absolute path? I want to create a file in some arbitrary location /Users/me/random/project3/<moreStuffInThePath. How would I go about doing this?
To create a directory I would do:
try FileManager.default.createDirectory(atPath: "/Users/me/random/project3/<directoryName>"
This worked fine for directories.
However the counterpart for creating files does not work:
FileManager.default.createFile(atPath: "Users/me/random/project3/something.txt", contents: someString.data(using: .utf8)) // always returns false
I have checked out other stack overflow threads on creating files. Everything I found was about creating files in the .documentDirectory or it was outdated.
Eg: How to create text file for writing
Create empty file swift
Read and write a String from text file
TLDR: How do I create text files/files with random extensions at arbitrary locations on the pc given I have the absolute path?
I would also be grateful if someone could explain why all tutorials available on this matter are about the document directory. Why is it so significant?
Thank you!
This is most likely because your app is sandboxed.
Go to your project settings, select the macOS target and go to "Signing and Capabilities". You should see something like this:
If your app needs to create files in arbitrary locations, you must remove the app sandbox by clicking on the "x" on the top right. Note that this will cause your app to be rejected from the Mac App Store.
If you want to upload your app to the Mac App Store, then you must keep the sandbox, and write to "user selected locations" only. Select "Read/Write" rather than "Read Only" next to "User Selected File". (Although it says "File", this includes directories too) This allows you to write to locations chosen by a user using something like an NSSavePanel.

how to create multiplatform file browser in ionic

I need help. I'm trying to create a multiplatform mobile application. One of the functionalities is a local file browser that will allow user to select a directory and create a list of file in this directory. I've already spent couple of hours on that issue and I can not find any solution for that.
I've checked http://ngcordova.com/docs/plugins/file/
But if I understand it correctly it is used when I already have a file, it not allows user to pick the directory.
I don't need anything fancy, it should as simple as possible
The Cordova FileSystem plugin (and ngCordova's wrapper) provide the ability the read directories from the file system. They do not provide any UI, so you would use the plugin to ask for a list of directories and then render it as you see fit. (A UL, a table, whatever.) To "browse" you could use a click handler on the list of directories such that when clicked, you then get the files/subdirectories of that folder. Again, the FS plugin adds support for doing that.

iOS - Allow user to download file from documents directory but not to upload file using iTunes

Here is a situation I have a data file in document directory which is being updated in the application every now and then. So I want to save it to my desktop using iTunes. But I don't want that the file should be uploaded back to my application. i.e. I want that user can download the file but can not upload any.
I was thinking to have the data file on some other location like Library and put a button on application settings saying "Prepare backup" that will copy that data file in Document directory, from where user can download it. If user uploads any thing it won't make any difference as my current file is in Library directory.
This is just a thought,
can anyone suggest me other way or the above way is good to go?
Edit: I just need that after the successful export user can view the data file (may be later) without support of the application.
You can't.
But what you can do is check (using an timer every 10 seconds) if a new file is added to the documents directory and then delete it programmatically.
But this ofcourse doesn't disable the replacement of files.

UIFileSharingEnabled use folders

I want to allow users add files to the application document folder, so I used the iTunes file sharing. The problem is they can only add single files with a flat structure. I want to drag and drop whole folder (even with sub folders) and keep the structure.
Questions I have:
is it possible with iTunes file sharing?
if not, is there an open source project that helps me with writing a pc side app that talks to the iPhone side app and pushes the files into it?
No you can't add Folder's/sub folders, iTunes will show just the files in the documents root. I think the only way to do that is to add it as zip file and you extract it in your app.
Maybe CocoaHTTPServer will help you.

iTunes file sharing - how to upload different folders?

i want to use the "file sharing" feature in my app. I want to create a photo-app which has no content when the user starts it. Therefore the user can select an image-folder on his mac or pc. After that and starting the app on his iphone or ipad, all the content of his image-folder will be viewable.
I think its only possible to add simple files to my app - not content folders, right?
Any ideas how i could do this?
Thanks for your time and help.
On your mac, rename the folder to folder.pkg.
You can now add folder.pkg to the documents for your app using iTunes File Sharing.
Once folder.pkg has been added, rename it to its original name.
Not sure how to do this with iTunes on a PC.
You cannot upload folder to the app.
one way to do so
create .zip file of that folder and upload.
extract that zip file from app.
checkout this project, It has a code to extract zip file.
https://github.com/ZipArchive/ZipArchive
I found that using iTunes 12, and iOS8, I can now ADD folders to an apps Documents folder using iTunes File Sharing. Previously it was only possible to add single files.
It is indeed possible to add a folder to and App's File Sharing space using iTunes version 12+. However, the iTunes upload button will not work for this, because its file selection interface insists on plain file selection only, excluding folders. The way which works is to drag-and-drop a folder from your PC to the iTunes File Sharing window.
Since the iTunes interface for handling file sharing is very poorly designed, is is worth recalling the tricks that you can use to perform operations on the File Sharing space, that iTunes does not provide a button for:
Rename a file or folder: click it once, wait for a couple of seconds, and click it again. This will replace the name with the renaming edit box
Delete a file or folder: select it, then hit the "Del" key on your keyboard
Upload a folder: drag-and-drop it from your computer copy
It remains impossible to directly see or alter the contents of a File Sharing folder in iTunes. My workaround for doing this is the following:
Download the folder to the computer
Make any desired change to the folder tree on the computer copy
Delete the File Sharing copy of the folder (or, optionally, rename it to something like folder.old for safety)
Upload the modified folder from the computer, using drag-and-drop
(optionally) Delete the safety copy in File Sharing, after verifying that the App works fine with the newly uploaded version of the folder
I hope this helps
I was not able to drag-and-drop a folder from my PC (Windows 10). But I found a free application called iFunbox that allowed me to copy a folder to an application's documents.