Cordova iOS 将文件下载到 iPhone 通用的 “Downloads” 文件夹中。

huangapple go评论76阅读模式
英文:

Cordova iOS download file to iPhones general "Downloads" folder

问题

在iOS上,是否有任何方法可以允许应用程序下载文件到iPhone的通用“下载”文件夹,用户可以在其iPhone上找到该文件夹(例如:使用iPhone的“文件”应用程序。 "文件"应用程序允许用户浏览iCloud存储或本地的“我的iPhone”文件夹。)

我已经编写了四种不同的方法,都成功地将文件下载到应用程序的子文件夹,但用户无法访问它们,因为用户无法导航到应用程序的子文件夹。

cordova-plugin-file-transfer - 允许您将文件下载到应用程序的子文件夹。

inAppBrowser - 不允许下载链接工作,iOS会阻止它。

我唯一找到的方法是使用类似Safari或Chrome的浏览器来下载文件...但这是一个不太理想的解决方案,会将用户带出我们的应用程序,并需要暴露在我们的Web服务器上的文件,需要额外的编码来只允许授权用户下载所选文件。

我不可能是唯一遇到这个问题的人...难道没有一种合适的方法允许文件下载到公共可访问的位置吗?

我是说,如果iOS想要完全隔离应用程序,至少可以在应用程序下载文件夹中创建符号链接,然后将其符号链接回主“下载”文件夹。这样用户就会看到类似以下的内容:

下载 --> 我的应用下载文件夹 --> downloadedFile.pdf

所以当用户点击打开“MyAppDownloadFolder”时,他们将打开应用程序隔离的下载文件夹。

英文:

on iOS, is there ANY method that can allow an app to download a file to the iPhones general "Downloads" folder that the user can find on their iPhone (IE: using the iPhones Files app The Files app opens allowing users to navigate the iCloud storage OR the local On My iPhone.)

I have written four different methods that all succeed in downloading files to app sub-folders, but the users can't get to them because there is no way for the user to navigate to the apps sub-folders.

cordova-plugin-file-transfer - allows you to download files to app sub-folders.

inAppBrowser - doesn't allow download links to work, iOS prevents it

The only thing I have found is using a browser like Safari or Chrome to download the file...but this is an ugly solution that takes the user out of our app AND it requires exposing files on our web server requiring additional coding to only allow authorized users to download the selected files.

I can't be the only person with this issue....is there not a proper method to allow files to be downloaded to a publicly accessible place?

I mean, if iOS wants to completely sandbox apps, at least create symbolic links to downloaded files in an app download folder that is then symbolically linked back to the main Downloads folder. So the user would see something like:

Downloads --> MyAppDownloadFolder --> downloadedFile.pdf

So when users click to open the MyAppDownloadFolder they would be opening up the app sandboxed download folder.

答案1

得分: 1

没有一种简单的方法可以在沙盒之外保存您的文件;您必须使用UIDocumentPickerViewController来让用户指定保存位置。

您可以轻松地将UIFileSharingEnabledLSSupportsOpeningDocumentsInPlace键添加到您的info.plist中,值为布尔值true

然后,在“我的iPhone”文件应用程序中,这将在您的应用名称下显示您的应用程序文档文件夹。

英文:

There isn't an easy way to save your files outside the Sandbox; You would have to use a UIDocumentPickerViewController to let the user specify a save location.

What you can do, easily, is add UIFileSharingEnabled and LSSupportsOpeningDocumentsInPlace keys to your info.plist with boolean true values.

This will then show your app's documents folder under your app name in "On my iPhone" in the Files app.

huangapple
  • 本文由 发表于 2023年3月7日 07:04:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/75656618.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定