SETUP
The following examples may require some or all of the following java classes to be imported:
CREATING A CONNECTION
This creates a connection so that you can interact with the server.
LISTING OWNED BUCKETS
This gets a list of Buckets that you own. This also prints out the bucket name and creation date of each bucket.
The output will look something like this:
CREATING A BUCKET
This creates a new bucket called my-new-bucket
LISTING A BUCKET’S CONTENT
This gets a list of objects in the bucket. This also prints out each object’s name, the file size, and last modified date.
The output will look something like this:
DELETING A BUCKET
Note
The Bucket must be empty! Otherwise it won’t work!
FORCED DELETE FOR NON-EMPTY BUCKETS
Attention
not available
CREATING AN OBJECT
This creates a file hello.txt with the string "Hello World!"
CHANGE AN OBJECT’S ACL
This makes the object hello.txt to be publicly readable, and secret_plans.txt to be private.
DOWNLOAD AN OBJECT (TO A FILE)
This downloads the object perl_poetry.pdf and saves it in /home/larry/documents
DELETE AN OBJECT
This deletes the object goodbye.txt
GENERATE OBJECT DOWNLOAD URLS (SIGNED AND UNSIGNED)
This generates an unsigned download URL for hello.txt. This works because we made hello.txt public by setting the ACL above. This then generates a signed download URL for secret_plans.txt that will work for 1 hour. Signed download URLs will work for the time period even if the object is private (when the time period is up, the URL will stop working).
Note
The java library does not have a method for generating unsigned URLs, so the example below just generates a signed URL.
The output will look something like this:
No comments:
Post a Comment