Package-level declarations
File operations.
File Operations
File operations are available from the FileOperations interface.
val fileManager: FileManager
val fileOperations: FileOperations = fileManager.operationsCreate Directory
Creates a directory with the name in the specified parent directory with the parentId.
val fileOperations: FileManager
lifecycleScope.launch(Dispatcher.IO) {
fileManager.operations.createDirectory(
name = "Directory Name",
parentId = "Parent Folder Node Id",
shareId = "Shared Link Id"
)
}If you want to create a directory in the "not my shared link", you must specify the sharedId. There may be some combinations:
parentId == null && sharedId == null - Creates a directory in the root of your cloud.
parentId == null && sharedId != null - Creates a directory in the root of the shared link.
parentId != null && sharedId != null - Creates a directory in a directory with parentId in a shared link with sharedId.
parentId != null && sharedId == null - Creates a directory in the folder with the parentId of your cloud.
Exceptions:
SessionIsNotInitializedException When session is not active.
IllegalArgumentException Parent directory is not found.
IllegalStateException Parent file is not directory.
IllegalStateException Same directory already exists.
UnauthorizedException Unauthorized access.
IllegalStateException Forbidden access.
Rename
Rename file
val fileOperations: FileManager
lifecycleScope.launch(Dispatcher.IO) {
fileManager.operations.rename(
fileId = "File id",
newName = "New name",
shareId = "Shared Link Id"
)
}Exceptions:
SessionIsNotInitializedException When session is not active.
UnauthorizedException Unauthorized access.
IllegalStateException Forbidden access.
Copy
Copy files to directory with parentId.
val fileOperations: FileManager
lifecycleScope.launch(Dispatcher.IO) {
fileManager.operations.copy(
fileIds = setOf("1", "2", "3"),
parentId = "Parent Folder Node Id",
shareId = "Shared Link Id"
)
}Exceptions:
SessionIsNotInitializedException When session is not active.
UnauthorizedException Unauthorized access.
IllegalStateException Forbidden access.
Move
Moves files to directory with parentId.
val fileOperations: FileManager
lifecycleScope.launch(Dispatcher.IO) {
fileManager.operations.move(
fileIds = setOf("1", "2", "3"),
parentId = "Parent Folder Node Id",
shareId = "Shared Link Id"
)
}Exceptions:
SessionIsNotInitializedException When session is not active.
UnauthorizedException Unauthorized access.
IllegalStateException Forbidden access.
Move To Trash
Moves files to trash.
val fileOperations: FileManager
lifecycleScope.launch(Dispatcher.IO) {
fileManager.operations.moveToTrash(
fileIds = setOf("1", "2", "3"),
shareId = "Shared Link Id"
)
}Exceptions:
SessionIsNotInitializedException When session is not active.
UnauthorizedException Unauthorized access.
IllegalStateException Forbidden access.
Mark As Opened
Mark file as opened.
val fileOperations: FileManager
lifecycleScope.launch(Dispatcher.IO) {
fileManager.operations.markAsOpened(
fileId = "File Id"
)
}Exceptions:
SessionIsNotInitializedException When session is not active.
Open Shared Link
TODO
Enqueue To Download
Adds files to the download queue. The method takes the caching type and priority as input.
Priority
REGULAR
HIGH
Cache Mode:
TEMPORARY - The file is deleted after a certain period of time
OFFLINE - The file is saved locally regardless of cache cleanup.
val fileOperations: FileManager
lifecycleScope.launch(Dispatcher.IO) {
fileManager.operations.enqueueToDownload(
fileId = "File Id",
priority = DownloadPriority.REGULAR,
cacheMode = CacheMode.TEMPORARY,
targetDirUri = Uri(),
)
}Exceptions:
IllegalStateException cacheMode and targetDirUri params is null.