micro-server icon indicating copy to clipboard operation
micro-server copied to clipboard

Refactor micro-s3 api

Open davidartplus opened this issue 9 years ago • 2 comments

davidartplus avatar Feb 16 '17 15:02 davidartplus

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?

jijisv avatar Feb 23 '17 22:02 jijisv

@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?

jijisv avatar Nov 01 '19 10:11 jijisv