diff --git a/storage-api/src/main/java/com/omh/android/storage/api/OmhStorageClient.kt b/storage-api/src/main/java/com/omh/android/storage/api/OmhStorageClient.kt index 20c2b51d..dce1d443 100644 --- a/storage-api/src/main/java/com/omh/android/storage/api/OmhStorageClient.kt +++ b/storage-api/src/main/java/com/omh/android/storage/api/OmhStorageClient.kt @@ -52,6 +52,13 @@ abstract class OmhStorageClient protected constructor( protected abstract fun getRepository(): OmhFileRepository + /** + * This method list files from an specific folder + * + * @param parentId The id of the folder you want to get the list of files + * + * @return An OmhTask with the result of the operation + */ fun listFiles(parentId: String): OmhTask { val getFilesListUseCase = GetFilesListUseCase(getRepository()) return OmhStorageTaskImpl { @@ -61,6 +68,15 @@ abstract class OmhStorageClient protected constructor( } } + /** + * This method create files in an specific folder + * + * @param name The name of the file to be created + * @param mimeType The mimeType of the file to be created + * @param parentId The id of the folder where the file will be created + * + * @return An OmhTask with the result of the operation + */ fun createFile( name: String, mimeType: String, @@ -74,6 +90,13 @@ abstract class OmhStorageClient protected constructor( } } + /** + * This method delete files with a given file id + * + * @param id The id of the desired file to delete + * + * @return An OmhTask with the result of the operation + */ fun deleteFile(id: String): OmhTask { val deleteFileUseCase = DeleteFileUseCase(getRepository()) return OmhStorageTaskImpl { @@ -83,6 +106,14 @@ abstract class OmhStorageClient protected constructor( } } + /** + * This method upload a file in an specific folder + * + * @param localFileToUpload The file to be uploaded + * @param parentId The id of the folder where the file will be uploaded + * + * @return An OmhTask with the result of the operation + */ fun uploadFile( localFileToUpload: File, parentId: String? @@ -95,6 +126,14 @@ abstract class OmhStorageClient protected constructor( } } + /** + * This method download a file with a given mime type and a given id + * + * @param fileId The id fo the file to be downloaded + * @param mimeType The mimeType of the file to be downloaded + * + * @return An OmhTask with the result of the operation + */ fun downloadFile(fileId: String, mimeType: String?): OmhTask { val downloadFileUseCase = DownloadFileUseCase(getRepository()) return OmhStorageTaskImpl { @@ -104,6 +143,14 @@ abstract class OmhStorageClient protected constructor( } } + /** + * This method update a remote file with the content of a local file + * + * @param localFileToUpload The local file to be uploaded + * @param fileId The id of the desired file to be updated + * + * @return An OmhTask with the result of the operation + */ fun updateFile( localFileToUpload: File, fileId: String diff --git a/storage-api/src/main/java/com/omh/android/storage/api/data/source/OmhFileRemoteDataSource.kt b/storage-api/src/main/java/com/omh/android/storage/api/data/source/OmhFileRemoteDataSource.kt index 6c67ea94..439b0157 100644 --- a/storage-api/src/main/java/com/omh/android/storage/api/data/source/OmhFileRemoteDataSource.kt +++ b/storage-api/src/main/java/com/omh/android/storage/api/data/source/OmhFileRemoteDataSource.kt @@ -22,18 +22,62 @@ import java.io.File interface OmhFileRemoteDataSource { + /** + * This method list files from an specific folder + * + * @param parentId The id of the folder you want to get the list of files + * + * @return A list of OmhFiles + */ fun getFilesList(parentId: String = "root"): List + /** + * This method create files in an specific folder + * + * @param name The name of the file to be created + * @param mimeType The mimeType of the file to be created + * @param parentId The id of the folder where the file will be created + * + * @return An OmhFile with the information of the created file. Null in case the file was not created + */ fun createFile(name: String, mimeType: String, parentId: String?): OmhFile? /** + * This method delete files with a given file id + * + * @param fileId The id of the desired file to delete + * * @return true if the file was deleted, false otherwise */ fun deleteFile(fileId: String): Boolean + /** + * This method upload a file in an specific folder + * + * @param localFileToUpload The file to be uploaded + * @param parentId The id of the folder where the file will be uploaded + * + * @return An OmhFile with the information of the uploaded file. Null in case the file was not uploaded + */ fun uploadFile(localFileToUpload: File, parentId: String?): OmhFile? + /** + * This method download a file with a given mime type and a given id + * + * @param fileId The id fo the file to be downloaded + * @param mimeType The mimeType of the file to be downloaded + * + * @return A ByteArrayOutputStream with the content of the downloaded file + */ fun downloadFile(fileId: String, mimeType: String?): ByteArrayOutputStream + /** + * This method update a remote file with the content of a local file + * + * @param localFileToUpload The local file to be uploaded + * @param fileId The id of the desired file to be updated + * + * @return An OmhFile with the information of the updated file + */ fun updateFile(localFileToUpload: File, fileId: String): OmhFile? } diff --git a/storage-api/src/main/java/com/omh/android/storage/api/domain/repository/OmhFileRepository.kt b/storage-api/src/main/java/com/omh/android/storage/api/domain/repository/OmhFileRepository.kt index 17013174..2c882b4e 100644 --- a/storage-api/src/main/java/com/omh/android/storage/api/domain/repository/OmhFileRepository.kt +++ b/storage-api/src/main/java/com/omh/android/storage/api/domain/repository/OmhFileRepository.kt @@ -22,15 +22,62 @@ import java.io.File interface OmhFileRepository { + /** + * This method list files from an specific folder + * + * @param parentId The id of the folder you want to get the list of files + * + * @return A list of OmhFiles + */ fun getFilesList(parentId: String = "root"): List + /** + * This method create files in an specific folder + * + * @param name The name of the file to be created + * @param mimeType The mimeType of the file to be created + * @param parentId The id of the folder where the file will be created + * + * @return An OmhFile with the information of the created file. Null in case the file was not created + */ fun createFile(name: String, mimeType: String, parentId: String?): OmhFile? + /** + * This method delete files with a given file id + * + * @param fileId The id of the desired file to delete + * + * @return true if the file was deleted, false otherwise + */ fun deleteFile(fileId: String): Boolean + /** + * This method upload a file in an specific folder + * + * @param localFileToUpload The file to be uploaded + * @param parentId The id of the folder where the file will be uploaded + * + * @return An OmhFile with the information of the uploaded file. Null in case the file was not uploaded + */ fun uploadFile(localFileToUpload: File, parentId: String?): OmhFile? + /** + * This method download a file with a given mime type and a given id + * + * @param fileId The id fo the file to be downloaded + * @param mimeType The mimeType of the file to be downloaded + * + * @return A ByteArrayOutputStream with the content of the downloaded file + */ fun downloadFile(fileId: String, mimeType: String?): ByteArrayOutputStream + /** + * This method update a remote file with the content of a local file + * + * @param localFileToUpload The local file to be uploaded + * @param fileId The id of the desired file to be updated + * + * @return An OmhFile with the information of the updated file + */ fun updateFile(localFileToUpload: File, fileId: String): OmhFile? }