Add bucket operations to micro-s3
delete bucket empty bucket delete object
delete bucket is in that list twice. Do you want to add 2 new operations, or is there a different third one?
They're different operations; the former is meant to delete an entire bucket and the latter only relates to individual objects inside the bucket
Micro-server update: Implement in S3ObjectWriter.java
public Try<Upload, Throwable> put(String key, byte[] byteArray){}
Implement in S3Utils.java
public Eval<UploadResult> writeAsync(String key, byte[] byteArray){} public Try<Upload, Throwable> writeSync(String key, byte[] byteArray){}
Linking https://github.com/aol/micro-server/issues/307 to this.
I'd suggest more functional approach here, few apis I can think of
Try<InputStream, MicroS3ClientException> readAsStream(String bucket, String key);
Try<T, MicroS3ClientException> readAsObject(String bucket, String key, Class<T> class);
Try<String, MicroS3ClientException> readAsString(String bucket, String key);
Try<InputStream, MicroS3ClientException> readAsStream(GetObjectReqest request);
Try<T, MicroS3ClientException> readAsObject(GetObjectReqest request, Class<T> class);
Try<String, MicroS3ClientException> readAsString(GetObjectReqest request);
Try<UploadResult, MicroS3ClientException> upload(String bucket, String key, InputStream inputStream);
Try<UploadResult, MicroS3ClientException> upload(String bucket, String key, File file);
Try<UploadResult, MicroS3ClientException> upload(String bucket, String key, String data);
Try<UploadResult, MicroS3ClientException> upload(String bucket, String key, byte[] bytes);
Try<UploadResult, MicroS3ClientException> upload(UploadObjectRequest uploadRequest);
Try<Upload, MicroS3ClientException> uploadAsync(String bucket, String key, InputStream inputStream);
Try<Upload, MicroS3ClientException> uploadAsync(String bucket, String key, File file);
Try<Upload, MicroS3ClientException> uploadAsync(String bucket, String key, String data);
Try<Upload, MicroS3ClientException> uploadAsync(String bucket, String key, byte[] bytes);
Try<Upload, MicroS3ClientException> uploadAsync(UploadObjectRequest uploadRequest);
Try<List<S3ObjectSummary>, MicroS3ClientException> list(String bucket, String keyPrefix);
Try<List<T>, MicroS3ClientException> list(String bucket, String keyPrefix, Function<S3ObjectSummary, T> mapper);
We can implement these in S3Utils OR deprecate the current S3Utils and create a new API (eg: MicroS3Client) with all these methods.
What do you think?
I like the idea of a new API.
Just one change: Try<List<S3ObjectSummary>, MicroS3ClientException> listSummaries(String bucket, String keyPrefix)
How about adding this? Try<UploadResult, MicroS3ClientException> upload(String bucket, String key, Supplier<PutObjectRequest> objectRequestSupplier)