Skip to content

feat(filesystem): support Temp directory #994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions filesystem/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ Required on Android, only when using <a href="#directory">`Directory.Documents`<
| **`Data`** | <code>'DATA'</code> | The Data directory On iOS it will use the Documents directory. On Android it's the directory holding application files. Files will be deleted when the application is uninstalled. | 1.0.0 |
| **`Library`** | <code>'LIBRARY'</code> | The Library directory On iOS it will use the Library directory. On Android it's the directory holding application files. Files will be deleted when the application is uninstalled. | 1.1.0 |
| **`Cache`** | <code>'CACHE'</code> | The Cache directory Can be deleted in cases of low memory, so use this directory to write app-specific files that your app can re-create easily. | 1.0.0 |
| **`Temp`** | <code>'TEMP'</code> | The Temp directory On iOS it will use the Temp directory. On Android it will use the Cache directory. Can be deleted in cases of low memory, so use this directory to write app-specific files that your app can re-create easily. | 1.1.1 |
| **`External`** | <code>'EXTERNAL'</code> | The external directory On iOS it will use the Documents directory On Android it's the directory on the primary shared/external storage device where the application can place persistent files it owns. These files are internal to the applications, and not typically visible to the user as media. Files will be deleted when the application is uninstalled. | 1.0.0 |
| **`ExternalStorage`** | <code>'EXTERNAL_STORAGE'</code> | The external storage directory On iOS it will use the Documents directory On Android it's the primary shared/external storage directory. It's not accesible on Android 10 unless the app enables legacy External Storage by adding `android:requestLegacyExternalStorage="true"` in the `application` tag in the `AndroidManifest.xml`. It's not accesible on Android 11 or newer. | 1.0.0 |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public File getDirectory(String directory) {
case "LIBRARY":
return c.getFilesDir();
case "CACHE":
case "TEMP":
return c.getCacheDir();
case "EXTERNAL":
return c.getExternalFilesDir(null);
Expand Down
4 changes: 4 additions & 0 deletions filesystem/ios/Plugin/Filesystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ import Foundation
return nil
}

return dir.appendingPathComponent(path)
} else if (directory === "TEMP") {
let dir = FileManager.default.temporaryDirectory

return dir.appendingPathComponent(path)
} else {
return URL(string: path)
Expand Down
11 changes: 11 additions & 0 deletions filesystem/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ export enum Directory {
*/
Cache = 'CACHE',

/**
* The Temp directory
* On iOS it will use the Temp directory.
* On Android it will use the Cache directory.
* Can be deleted in cases of low memory, so use this directory to write app-specific files
* that your app can re-create easily.
*
* @since 1.1.1
*/
Temp = 'TEMP',

/**
* The external directory
* On iOS it will use the Documents directory
Expand Down