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

Add bucket operations to micro-s3

Open davidartplus opened this issue 9 years ago • 6 comments

delete bucket empty bucket delete object

davidartplus avatar Feb 10 '17 10:02 davidartplus

delete bucket is in that list twice. Do you want to add 2 new operations, or is there a different third one?

johnmcclean avatar Feb 13 '17 13:02 johnmcclean

They're different operations; the former is meant to delete an entire bucket and the latter only relates to individual objects inside the bucket

davidartplus avatar Feb 13 '17 15:02 davidartplus

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){}

davidartplus avatar Feb 16 '17 15:02 davidartplus

Linking https://github.com/aol/micro-server/issues/307 to this.

jijisv avatar Feb 24 '17 22:02 jijisv

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?

jijisv avatar Feb 24 '17 22:02 jijisv

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)

davidartplus avatar Feb 27 '17 16:02 davidartplus