Extension to get file

I am in the need of opening a file on disk on Android and iOS. I have tried for a few hours to do it myself, but as I am not familiar with Java nor C++ it is taking an aweful lot of time (which I would prefer to spend on improving other parts of the app :upside_down_face:). So here is me hopping that someone have already done it.

So - Have anyone written an extension for getting files on disk? :sweat_smile:

I am not sure this is possible to open a file from disk on iOS, only image from the gallery, as I remember.
With Android, it should be fine.

Could you please explain what do you want to open and how do you want to use it? Maybe some examples of other games when this was implemented?

Personally I want to open a zip file, but it would be nice if a filter can be specified when calling the hypothetical extension.

I have a prototype of the feature I want to implement working by downloading the zip from the web by writing the http response to a file. I then unzip it and import the content. This works fine but it requires the user to host the content in a set location (like github, because I need to predict urls, redirects and such), this makes a feature like this not very user friendly.

I can not think of a game where this was implemented, my app isn’t a game. :slight_smile:

What kind of functionality does iOS and Android have for this kind of thing?

I’m thinking maybe a combination of GitHub - Lerg/extension-directories: Provides path to various system directories. and GitHub - britzl/defold-lfs: LuaFileSystem port to a Defold native extension could work.

1 Like

or https://github.com/andsve/def-diags

Android got the document-provider, question is if one should assume they have a file browser, if one should be built in the extension, or if they don’t have one simply show a warning.

I am not 100% this is it (as I am very unfamiliar with native android/iOS) but iOS got something called UIDocumentPickerViewController.

I think with this kind of setup you would have to do it ā€œblindā€. Tell the user "put you zipfile in your documents folder and name it please_import_this_file.zip." Which doesn’t feel very nice and user friendly.

def-diags doesn’t have support for iOS/Android currently, have been talking to Sven a bit about it already seems that it wouldn’t be ā€œnone trivialā€ to add it to def-diags with a similar interface.