java - Multiple Uploads of unknown number of files to S3 with JetS3t -


from sample code examples of jets3t code follows: if don't know number of files downloaded beginning? e.g application thumbnails in s3, , client application user scrolls through list of thumbnails.

download objects local files

the multi-threading services provide method download multiple objects @ time, use must first prepare somewhere put data associated each object. obvious place put data file, let's go through example of downloading object data files. download our objects files first must create downloadpackage class each object. class simple container merely associates object file, object's data written. create downloadpackage each object, associate object output file.

 downloadpackage[] downloadpackages = new downloadpackage[5];    downloadpackages[0] = new downloadpackage(objects[0],        new file(objects[0].getkey()));    downloadpackages[1] = new downloadpackage(objects[1],        new file(objects[1].getkey()));    downloadpackages[2] = new downloadpackage(objects[2],        new file(objects[2].getkey()));    downloadpackages[3] = new downloadpackage(objects[3],        new file(objects[3].getkey()));    downloadpackages[4] = new downloadpackage(objects[4],        new file(objects[4].getkey()));     // download objects.    simplemulti.downloadobjects(bucket, downloadpackages);    system.out.println("downloaded objects current working directory"); 

any suggestions cases? in advance

antonis

you can list objects in bucket download , filter keys according rules define. can start multipart download.

get keys bucket:


public list getfileslist(string accesskey, string secretkey ,string bucketname ,string directorypathrelativetobucket) { list keys = new arraylist(); org.jets3t.service.model.s3object[] objects = new org.jets3t.service.model.s3object[]{}; try { // create credentials object , service access s3 account org.jets3t.service.security.awscredentials mycredentials = new org.jets3t.service.security.awscredentials(accesskey, secretkey);

s3service service = new rests3service(mycredentials); objects = service.listobjects(bucketname ,directorypathrelativetobucket, null); log.info("got bucket listing bucket[" + bucketname + "]"); } catch (s3serviceexception e) { log.error("failed or object listing bucket[" + bucketname + "] due exception:", e); } (org.jets3t.service.model.s3object s3object : objects) { if (s3object.getkey().contains("$") == false) { keys.add(s3object.getkey()); } } return keys; }

after filtering keys can download particular part of key-list.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -