Package de.dlr.proseo.storagemgr.s3
Klasse S3Storage
java.lang.Object
de.dlr.proseo.storagemgr.s3.S3Storage
- Alle implementierten Schnittstellen:
Storage
An implementation of the Storage interface for a S3-based file system,
providing functionality to interact with the storage system, that is
retrieving information about the storage, performing file operations, and
path conversion.
- Autor:
- Denys Chaykovskiy
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungaddFSPrefix
(String path) Adds the file system prefix to the path.addFSPrefix
(List<String> paths) Adds the file system prefix to paths.boolean
bucketExists
(String bucketName) Checks if the bucket exists.createStorageFile
(String relativePath, String content) Creates the physical storage file.delete
(StorageFile storageFileOrDir) Deletes the file or directory recursively from the storage.Deletes the file or directory recursively from the storage.void
deleteBucket
(String bucketName) Deletes the bucket in storage.deleteFile
(StorageFile storageFile) Deletes the storage file from storage.download
(StorageFile sourceFileOrDir, StorageFile targetFileOrDir) Downloads the file or directory recursively.downloadFile
(StorageFile sourceFile, StorageFile targetFileOrDir) Downloads the file from storage.boolean
fileExists
(StorageFile storageFile) Checks if the file exists.Gets the absolute base path (fs prefix + bucket + base path), depends on fs.Gets all files (absolute paths) from storage.getAbsoluteFiles
(String relativePath) Gets files (absolute paths) from storage with the given relative path.getAbsolutePath
(String relativePath) Gets the absolute path (s3://<bucket>/<relativePath>).getAbsolutePath
(List<String> relativePaths) Gets the absolute paths (s3://<bucket>/<relativePath>).Gets the base path.Gets the bucket.Gets the buckets from storage.getFileContent
(StorageFile storageFile) Gets the file content.long
getFileSize
(StorageFile storageFile) Gets the file size.getInputStream
(StorageFile storageFile) Gets the input stream from the file.Gets all files from storage.getRelativeFiles
(String folder) Gets the files from storage with the given prefix (folder).getRelativePath
(String absolutePath) Gets the relative path from the absolute path by removing the S3 prefix, bucket, and left slash.getRelativePath
(List<String> absolutePaths) Gets the relative paths from the absolute paths by removing the S3 prefix, bucket, and left slash.Gets the source path.getStorageFile
(String relativePath) Gets the Storage File.Gets the storage files.Gets the storage type.boolean
isDirectory
(StorageFile storageFileOrDir) Checks if the storage file or directory is a directory.boolean
isFile
(StorageFile storageFileOrDir) Checks if the storage file or directory is a file (no slash at the end of the path).void
Sets the bucket.upload
(StorageFile sourceFileOrDir) Uploads the file or directory recursively to the storage.upload
(StorageFile sourceFileOrDir, StorageFile targetFileOrDir) Uploads the file or directory recursively to storage.uploadFile
(StorageFile sourceFile) Uploads the file to the storage.uploadFile
(StorageFile sourceFile, StorageFile targetFileOrDir) Uploads the file to storage.uploadSourceFile
(String relativeSourceFile) Uploads the source file.uploadSourceFileOrDir
(String relativeSourceFileOrDir) Uploads the source file or directory recursively to the storage.
-
Konstruktordetails
-
S3Storage
Constructor with the s3 configuration- Parameter:
cfg
- s3 configuration- Löst aus:
IOException
- if an I/O exception occurs
-
-
Methodendetails
-
getStorageType
Gets the storage type.- Angegeben von:
getStorageType
in SchnittstelleStorage
- Gibt zurück:
- the storage type
-
getBasePath
Gets the base path.- Angegeben von:
getBasePath
in SchnittstelleStorage
- Gibt zurück:
- the base path
-
getAbsoluteBasePath
Gets the absolute base path (fs prefix + bucket + base path), depends on fs. In other words, it is the absolute path without the relative path in this S3 version. s3://bucket/- Angegeben von:
getAbsoluteBasePath
in SchnittstelleStorage
- Gibt zurück:
- the absolute base path
-
getSourcePath
Gets the source path.- Angegeben von:
getSourcePath
in SchnittstelleStorage
- Gibt zurück:
- the source path
-
setBucket
Sets the bucket.- Angegeben von:
setBucket
in SchnittstelleStorage
- Parameter:
bucket
- the bucket to set- Löst aus:
IOException
- if an I/O exception occurs
-
getBucket
Gets the bucket. -
getBuckets
Gets the buckets from storage.- Angegeben von:
getBuckets
in SchnittstelleStorage
- Gibt zurück:
- the list of buckets
- Löst aus:
IOException
- if an I/O exception occurs
-
bucketExists
Checks if the bucket exists.- Angegeben von:
bucketExists
in SchnittstelleStorage
- Parameter:
bucketName
- the name of the bucket- Gibt zurück:
- true if the bucket exists
- Löst aus:
IOException
- if an I/O exception occurs
-
deleteBucket
Deletes the bucket in storage.- Angegeben von:
deleteBucket
in SchnittstelleStorage
- Parameter:
bucketName
- the bucket to delete- Löst aus:
IOException
- if the bucket cannot be deleted
-
getRelativeFiles
Gets the files from storage with the given prefix (folder).- Angegeben von:
getRelativeFiles
in SchnittstelleStorage
- Parameter:
folder
- the prefix (folder) for search in storage- Gibt zurück:
- the list of files with the given prefix
- Löst aus:
IOException
- if an I/O exception occurs
-
getRelativeFiles
Gets all files from storage.- Angegeben von:
getRelativeFiles
in SchnittstelleStorage
- Gibt zurück:
- the list of all files from storage
- Löst aus:
IOException
- if an I/O exception occurs
-
getAbsoluteFiles
Gets files (absolute paths) from storage with the given relative path.- Angegeben von:
getAbsoluteFiles
in SchnittstelleStorage
- Parameter:
relativePath
- the relative path for search in storage- Gibt zurück:
- the list of files with the given prefix
- Löst aus:
IOException
- if an I/O exception occurs
-
getAbsoluteFiles
Gets all files (absolute paths) from storage.- Angegeben von:
getAbsoluteFiles
in SchnittstelleStorage
- Gibt zurück:
- the list of all files from storage
- Löst aus:
IOException
- if an I/O exception occurs
-
getRelativePath
Gets the relative path from the absolute path by removing the S3 prefix, bucket, and left slash.- Angegeben von:
getRelativePath
in SchnittstelleStorage
- Parameter:
absolutePath
- the absolute path- Gibt zurück:
- the relative path
-
getRelativePath
Gets the relative paths from the absolute paths by removing the S3 prefix, bucket, and left slash.- Angegeben von:
getRelativePath
in SchnittstelleStorage
- Parameter:
absolutePaths
- the absolute paths- Gibt zurück:
- the relative paths
-
getAbsolutePath
Gets the absolute path (s3://<bucket>/<relativePath>).- Angegeben von:
getAbsolutePath
in SchnittstelleStorage
- Parameter:
relativePath
- the relative path- Gibt zurück:
- the absolute file depending on the storage file system
-
getAbsolutePath
Gets the absolute paths (s3://<bucket>/<relativePath>).- Angegeben von:
getAbsolutePath
in SchnittstelleStorage
- Parameter:
relativePaths
- the relative paths- Gibt zurück:
- the absolute paths depending on the storage file system
-
getStorageFile
Gets the Storage File.- Angegeben von:
getStorageFile
in SchnittstelleStorage
- Parameter:
relativePath
- the relative path in storage to the file- Gibt zurück:
- the storage file object
-
getStorageFiles
Gets the storage files.- Angegeben von:
getStorageFiles
in SchnittstelleStorage
- Gibt zurück:
- the list of storage files
- Löst aus:
IOException
- if an I/O exception occurs
-
createStorageFile
Creates the physical storage file.- Angegeben von:
createStorageFile
in SchnittstelleStorage
- Parameter:
relativePath
- the relative path of the filecontent
- the content of the file- Gibt zurück:
- the storage file object of the created file
- Löst aus:
IOException
- if the file cannot be created
-
fileExists
Checks if the file exists.- Angegeben von:
fileExists
in SchnittstelleStorage
- Parameter:
storageFile
- the storage file to check- Gibt zurück:
- true if the file exists physically
- Löst aus:
IOException
- if an I/O exception occurs
-
isFile
Checks if the storage file or directory is a file (no slash at the end of the path).- Angegeben von:
isFile
in SchnittstelleStorage
- Parameter:
storageFileOrDir
- the storage file or directory- Gibt zurück:
- true if the storage file is a file
- Löst aus:
IOException
- if an I/O exception occurs
-
isDirectory
Checks if the storage file or directory is a directory.- Angegeben von:
isDirectory
in SchnittstelleStorage
- Parameter:
storageFileOrDir
- the storage file or directory- Gibt zurück:
- true if the storage file is a file
- Löst aus:
IOException
- if an I/O exception occurs
-
getFileSize
Gets the file size.- Angegeben von:
getFileSize
in SchnittstelleStorage
- Parameter:
storageFile
- the storage file- Gibt zurück:
- the file size of the storage file
- Löst aus:
IOException
- if an I/O exception occurs
-
getFileContent
Gets the file content.- Angegeben von:
getFileContent
in SchnittstelleStorage
- Parameter:
storageFile
- the storage file- Gibt zurück:
- the file content
- Löst aus:
IOException
- if an error occurs while getting the file content
-
uploadFile
Uploads the file to storage.- Angegeben von:
uploadFile
in SchnittstelleStorage
- Parameter:
sourceFile
- the source file to uploadtargetFileOrDir
- the target file or directory in the storage- Gibt zurück:
- the uploaded storage file
- Löst aus:
IOException
- if the file cannot be uploaded
-
upload
public List<String> upload(StorageFile sourceFileOrDir, StorageFile targetFileOrDir) throws IOException Uploads the file or directory recursively to storage.- Angegeben von:
upload
in SchnittstelleStorage
- Parameter:
sourceFileOrDir
- the source file or directorytargetFileOrDir
- the target file or directory in the storage- Gibt zurück:
- the list of uploaded files
- Löst aus:
IOException
- if the file or directory cannot be uploaded
-
upload
Uploads the file or directory recursively to the storage.- Angegeben von:
upload
in SchnittstelleStorage
- Parameter:
sourceFileOrDir
- the source file or dir to upload- Gibt zurück:
- the list of uploaded files
- Löst aus:
IOException
- if the file or directory cannot be uploaded
-
uploadFile
Uploads the file to the storage.- Angegeben von:
uploadFile
in SchnittstelleStorage
- Parameter:
sourceFile
- the source file to upload- Gibt zurück:
- the path of the uploaded file
- Löst aus:
IOException
- if the file cannot be uploaded
-
uploadSourceFileOrDir
Uploads the source file or directory recursively to the storage.- Angegeben von:
uploadSourceFileOrDir
in SchnittstelleStorage
- Parameter:
relativeSourceFileOrDir
- the relative path to source file or directory- Gibt zurück:
- the list of uploaded to storage source files
- Löst aus:
IOException
- if the file cannot be uploaded
-
uploadSourceFile
Uploads the source file.- Angegeben von:
uploadSourceFile
in SchnittstelleStorage
- Parameter:
relativeSourceFile
- the relative path to source file- Gibt zurück:
- the uploaded to storage source file
- Löst aus:
IOException
- if the file cannot be uploaded
-
download
public List<String> download(StorageFile sourceFileOrDir, StorageFile targetFileOrDir) throws IOException Downloads the file or directory recursively.- Angegeben von:
download
in SchnittstelleStorage
- Parameter:
sourceFileOrDir
- the source file or directory in the storagetargetFileOrDir
- the target file or directory- Gibt zurück:
- the list of downloaded files
- Löst aus:
IOException
- if the file cannot be downloaded
-
downloadFile
Downloads the file from storage.- Angegeben von:
downloadFile
in SchnittstelleStorage
- Parameter:
sourceFile
- the storage source file to downloadtargetFileOrDir
- the target file or directory- Gibt zurück:
- the Storage File object with the downloaded file
- Löst aus:
IOException
- if the file cannot be downloaded
-
delete
Deletes the file or directory recursively from the storage.- Angegeben von:
delete
in SchnittstelleStorage
- Parameter:
storageFileOrDir
- the Storage file or directory to delete- Gibt zurück:
- the list of deleted files from storage
- Löst aus:
IOException
- if the file or directory cannot be deleted
-
deleteFile
Deletes the storage file from storage.- Angegeben von:
deleteFile
in SchnittstelleStorage
- Parameter:
storageFile
- the storage file to delete- Gibt zurück:
- the deleted storage file
- Löst aus:
IOException
- if the file cannot be deleted
-
delete
Deletes the file or directory recursively from the storage.- Angegeben von:
delete
in SchnittstelleStorage
- Parameter:
relativeFileOrDir
- the Storage file or directory to delete- Gibt zurück:
- the list of deleted files from storage
- Löst aus:
IOException
- if the file or directory cannot be deleted
-
addFSPrefix
Adds the file system prefix to the path.- Angegeben von:
addFSPrefix
in SchnittstelleStorage
- Parameter:
path
- the path to extend- Gibt zurück:
- the file system prefix + "|" + path
-
addFSPrefix
Adds the file system prefix to paths.- Angegeben von:
addFSPrefix
in SchnittstelleStorage
- Parameter:
paths
- the paths to extend- Gibt zurück:
- the list of file system prefix + path
-
getInputStream
Gets the input stream from the file.- Angegeben von:
getInputStream
in SchnittstelleStorage
- Parameter:
storageFile
- the storage file- Gibt zurück:
- the input stream from the file
- Löst aus:
IOException
- if an error occurs while getting the input stream
-