micro-server
micro-server copied to clipboard
Refactor micro-s3 api
I'd suggest more functional approach for S3Utils, 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);
If you are okay with these, I can start working on these. What do you think?
@johnmcclean - planning to start this refactoring,
The plan is to deprecate the current S3Utils, ReadUtils, and create a new class S3Client which will have the above methods.
Do you have any suggestions on the new API?