So, I began studying the upload mechanism with AWS. Also, watching several other examples, I have noticed that I don't actually get one thing ( even though I have read the documentation over and over, at those specific parts). At the creation of a AWS account, you are given a key. But also, there is the notion of ObjectKey.
So, given this example : http://docs.aws.amazon.com/AmazonS3/latest/dev/UploadObjSingleOpJava.html
especially, this piece of code :
private static String bucketName = "*** Provide bucket name ***";
private static String keyName = "*** Provide key ***";
private static String uploadFileName = "*** Provide file name ***";
I have to ask : what does that keyName represent ? It is the name of the object ( name that will be found in the bucket ) or is it the secret key given on account creation?
The keyName is the "name" (=unique identifier) by which your file will be stored in the S3 bucket.
The object key (or key name) uniquely identifies the object in an Amazon S3 bucket. Object metadata is a set of name-value pairs. For more information about object metadata, see Working with object metadata. When you create an object, you specify the key name, which uniquely identifies the object in the bucket.
A key pair is a combination of a public key that is used to encrypt data and a private key that is used to decrypt data. For more information about key pairs, see Amazon EC2 Key Pairs in the Amazon EC2 User Guide for Linux Instances.
You use key pairs to connect to an Amazon EC2 instance. You must provide the key pair to Amazon EC2 when you create the instance, and then use that key pair to authenticate when you connect to the instance. For additional command examples, see the AWS CLI reference guide .
AWS S3 is, at the most basic level, just a key/value store. When you upload an object (file) to S3 you specify a unique public key for the object. In S3 the keys look like file paths, which can lead to some confusion since you don't need to do things like create subdirectories, etc. What this means, in a nutshell, is that you can upload a file using a key like /some/key/to/an/image/file.jpg
without first having to create the path /some/key/to/an/image
.
If you have static web hosting enabled for your S3 bucket then as soon as you upload file.jpg
using this key then you should be able to view it in your web browser via a URL along the lines of https://s3-eu-west-1.amazonaws.com/<bucket_name>/some/key/to/an/image/file.jpg
, depending on the region that the bucket is located in.
The keyName is the "name" (=unique identifier) by which your file will be stored in the S3 bucket.
For example :
private static String uploadFileName = "c:\mydir\myfile.txt";
private static String keyName ="mydirinbucket/myfile.txt";
(N.B. You can use "/" characters to use "directories" in your S3 bucket )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With