| title | Getting Started |
|---|---|
| layout | default |
| nav_order | 2 |
Android OMH Storage is a project that integrates various cloud storage providers into Android applications. It offers a unified API to work with different storage providers.
Before integrating any storage provider into your Android project, ensure you meet the following requirements:
- Gradle version: 7.0 or higher
- Android API level: 23(GoogleDrive, Dropbox), 26(OneDrive) or higher
To integrate a storage provider into your Android project, follow the specific steps for each provider:
Any operation you can perform on files can also be applied to folders.
Retrieves the root folder path of the storage service. Useful when you want to list files in the root folder.
val rootPath = omhStorageClient.rootFolderLists files from a specific folder.
val files = omhStorageClient.listFiles(parentId = "folderId")Lists files with names containing the specified query value.
val searchResults = omhStorageClient.search(query = "fileName")Creates a folder in a specific folder.
val newFile = omhStorageClient.createFolder(
name = "fileName",
parentId = "folderId"
)Creates a file in a specific folder.
val newFile = omhStorageClient.createFileWithMimeType(
name = "fileName",
mimeType = "fileMimeType",
parentId = "folderId"
)Creates a file in a specific folder.
val newFile = omhStorageClient.createFileWithExtension(
name = "fileName",
extension = "ext",
parentId = "folderId"
)Updates a remote file with the content of a local file.
val updatedFile = omhStorageClient.updateFile(
localFileToUpload = File("localFilePath"),
fileId = "fileId"
)Moves a file with the given file ID in the trash.
omhStorageClient.deleteFile(id = "fileId")Permanently deletes a file with the given file ID.
omhStorageClient.permanentlyDeleteFile(id = "fileId")Uploads a local file to a specific folder.
val uploadedFile = omhStorageClient.uploadFile(
localFileToUpload = File("localFilePath"),
parentId = "folderId"
)Downloads a file with the given file ID.
val fileContent = omhStorageClient.downloadFile(fileId = "fileId")Exports a provider application file with the given file ID to a specified MIME type.
val exportedFileContent = omhStorageClient.exportFile(
fileId = "fileId",
exportedMimeType = "desiredMimeType"
)Retrieves the metadata of a file with the given file ID.
val fileMetadata = omhStorageClient.getFileMetadata(fileId = "fileId")For more details on file metadata support for each provider, please refer to the File metadata documentation.
Retrieves the versions of a file with the given file ID.
val fileVersions = omhStorageClient.getFileVersions(fileId = "fileId")Downloads a specific version of a file.
val versionContent = omhStorageClient.downloadFileVersion(
fileId = "fileId",
versionId = "versionId"
)Lists the permissions of a file with the given file ID.
val permissions = omhStorageClient.getFilePermissions(fileId = "fileId")Creates a permission for a file.
val userPermission = OmhCreatePermission.CreateIdentityPermission(
OmhPermissionRole.WRITER,
OmhPermissionRecipient.User("test@email.com")
)
val newPermission = omhStorageClient.createPermission(
fileId = "fileId",
permission = userPermission,
sendNotificationEmail = true,
emailMessage = "Optional message"
)For more details on file permissions support for each provider, please refer to the File permissions documentation.
Updates the role of a permission in a file.
val updatedPermission = omhStorageClient.updatePermission(
fileId = "fileId",
permissionId = "permissionId",
role = OmhPermissionRole.ROLE
)Deletes a permission with the given permission ID from a file.
omhStorageClient.deletePermission(
fileId = "fileId",
permissionId = "permissionId"
)Retrieves the file URL.
val webUrl = omhStorageClient.getWebUrl(fileId = "fileId")Recursively calculates the total size of files in the specified folder, in bytes.
val totalFolderSize = omhStorageClient.folderSize(folderId = "folderId")Retrieves the storage quota allocated by the storage provider, in bytes. It is entirely depends on storage provider's calculations, so actual figures may differ.
val quotaAllocated = omhStorageClient.getStorageQuota()Retrieves the storage quota currently in use, in bytes. It is entirely depends on storage provider's calculations, so actual figures may differ.
val quotaUsed = omhStorageClient.getStorageUsage()Retrieves the ID of the file/folder at specified path on the cloud storage (which the user has access to).
val fileOrFolderId = omhStorageClient.resolvePath("path/to/the/fileorfolder")For a more in depth view on the available methods, access the Reference API.
Explore the sample app included in the repository to see the implementation of storage with Google Drive and other storage providers. The sample app demonstrates the integration and usage of the various storage providers, providing a practical example to help you get started quickly.