Package de.dlr.proseo.storagemgr.s3
Klasse S3DAL
java.lang.Object
de.dlr.proseo.storagemgr.s3.S3DAL
A data access layer for interacting with a S3-based storage system. It
provides various methods to perform operations such as retrieving files,
checking file or directory existence, obtaining file content, uploading
files, downloading files, and deleting files or directories within the S3
storage system.
This class utilizes the Amazon S3 SDK v2 for S3 client operations and
requires AWS credentials and a S3 configuration to be initialized.
- Autor:
- Denys Chaykovskiy
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungboolean
bucketExists
(String bucketName) Checks if a bucket exists in the storage system.Deletes a file or directory.void
deleteBucket
(String bucketName) Deletes a bucket from the storage system.deleteFile
(String filepath) Deletes a file.Deletes files.deleteFiles
(List<String> toDeleteList) Deletes files.Downloads a file or directory with a prefix match from the storage system.Downloads a file or directory from the storage system.downloadFile
(String sourceFile, String targetFileOrDir) Downloads a file from the storage system.boolean
fileExists
(String filePath) Checks if a file exists in the storage system.Gets the current bucket.Gets the list of available buckets.Gets the S3 configuration used by this S3DAL instance.getFileContent
(String filePath) Retrieves the content of the file specified by the file path.getFileName
(String path) Gets the name of the file from the specified path.getFiles()
Retrieves a list of all files in the current bucket.Retrieves a list of files that match the specified folder (prefix).long
getFileSize
(String filePath) Retrieves the size of the file specified by the file path.getInputStream
(String relativePath) Gets an input stream from a file in the storage system.void
Initializes the S3 v1 client.void
Initializes the S3 v2 client.boolean
Checks if the specified path represents a file (not a directory).void
Sets the bucket to use for operations.Uploads a file or directory to the storage system.Uploads a file or directory to the storage system.uploadFile
(String sourceFile, String targetFileOrDir) Uploads a file to the storage system.
-
Konstruktordetails
-
S3DAL
Constructor- Parameter:
cfg
- s3Configuration- Löst aus:
IOException
- if an I/O exception occurs
-
-
Methodendetails
-
getConfiguration
Gets the S3 configuration used by this S3DAL instance.- Gibt zurück:
- the S3Configuration object
-
initS3ClientV1
Initializes the S3 v1 client.- Löst aus:
IOException
- if an I/O exception occurs
-
initS3ClientV2
Initializes the S3 v2 client.- Löst aus:
IOException
- if an I/O exception occurs
-
getFiles
Retrieves a list of all files in the current bucket.- Gibt zurück:
- a list of all file paths
- Löst aus:
IOException
- if an I/O exception occurs
-
getFiles
Retrieves a list of files that match the specified folder (prefix).- Parameter:
folder
- the folder (prefix) to match- Gibt zurück:
- a list of file paths that match the folder
- Löst aus:
IOException
- if an I/O exception occurs
-
fileExists
Checks if a file exists in the storage system.- Parameter:
filePath
- the file path- Gibt zurück:
- true if the file exists, false otherwise
- Löst aus:
IOException
- if an I/O exception occurs
-
isFile
Checks if the specified path represents a file (not a directory).- Parameter:
path
- the path to check- Gibt zurück:
- true if the path represents a file, false otherwise
-
getFileName
Gets the name of the file from the specified path.- Parameter:
path
- the file path- Gibt zurück:
- the name of the file
-
getFileSize
Retrieves the size of the file specified by the file path.- Parameter:
filePath
- the file path- Gibt zurück:
- the size of the file in bytes
- Löst aus:
IOException
- if an I/O exception occurs
-
getFileContent
Retrieves the content of the file specified by the file path.- Parameter:
filePath
- the file path- Gibt zurück:
- the content of the file
- Löst aus:
IOException
- if an I/O exception occurs
-
uploadFile
Uploads a file to the storage system.- Parameter:
sourceFile
- the source file to uploadtargetFileOrDir
- the target file or directory in the storage system- Gibt zurück:
- the uploaded file path in the storage system
- Löst aus:
IOException
- if an I/O exception occurs if the file cannot be uploaded
-
upload
Uploads a file or directory to the storage system.- Parameter:
sourceFileOrDir
- the source file or directory to uploadtargetFileOrDir
- the target file or directory in the storage system- Gibt zurück:
- a list of uploaded file paths in the storage system
- Löst aus:
IOException
- if an I/O exception occurs if the file or directory cannot be uploaded
-
upload
Uploads a file or directory to the storage system.- Parameter:
sourceFileOrDir
- the source file or directory to upload- Gibt zurück:
- a list of uploaded file or directory paths in the storage system
- Löst aus:
IOException
- if an I/O exception occurs if the file or directory cannot be uploaded
-
downloadFile
Downloads a file from the storage system.- Parameter:
sourceFile
- the source file in the storage system to downloadtargetFileOrDir
- the target file or directory to download to- Gibt zurück:
- the downloaded file path
- Löst aus:
IOException
- if an I/O exception occurs if the file cannot be downloaded
-
download
Downloads a file or directory from the storage system.- Parameter:
sourceFileOrDir
- the source file or directory in the storage system to downloadtargetFileOrDir
- the target file or directory to download to- Gibt zurück:
- a list of downloaded file or directory paths
- Löst aus:
IOException
- if an I/O exception occurs if the file or directory cannot be downloaded
-
download
Downloads a file or directory with a prefix match from the storage system.- Parameter:
prefixFileOrDir
- the prefix file or directory to match- Gibt zurück:
- a list of downloaded file paths
- Löst aus:
IOException
- if an I/O exception occurs if the file or directory cannot be downloaded
-
delete
Deletes a file or directory.- Parameter:
fileOrDir
- the file or directory to delete- Gibt zurück:
- a list of deleted file paths
- Löst aus:
IOException
- if an I/O exception occurs
-
deleteFile
Deletes a file.- Parameter:
filepath
- the file path- Gibt zurück:
- the deleted file path
- Löst aus:
IOException
- if an I/O exception occurs
-
deleteFiles
Deletes files.- Gibt zurück:
- a list of deleted file paths
- Löst aus:
IOException
- if an I/O exception occurs
-
deleteFiles
Deletes files.- Parameter:
toDeleteList
- a list of file or directory paths to delete- Gibt zurück:
- a list of deleted file paths
-
setBucket
Sets the bucket to use for operations.- Parameter:
bucket
- the bucket name- Löst aus:
IOException
- if an I/O exception occurs
-
getBucket
Gets the current bucket.- Gibt zurück:
- the current bucket name
-
getBuckets
Gets the list of available buckets.- Gibt zurück:
- a list of bucket names
- Löst aus:
IOException
- if an I/O exception occurs
-
bucketExists
Checks if a bucket exists in the storage system.- Parameter:
bucketName
- the bucket name- Gibt zurück:
- true if the bucket exists, false otherwise
- Löst aus:
IOException
- if an I/O exception occurs
-
deleteBucket
Deletes a bucket from the storage system.- Parameter:
bucketName
- the bucket name- Löst aus:
IOException
- if an I/O exception occurs
-
getInputStream
Gets an input stream from a file in the storage system.- Parameter:
relativePath
- the relative file path- Gibt zurück:
- an InputStream object for reading the file content
- Löst aus:
IOException
- if an I/O exception occurs
-