Reputation: 829
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?
Upvotes: 10
Views: 24366
Reputation: 1
The object key (or key name) uniquely identifies the object in an Amazon S3 bucket. When you create an object, you specify the key name, which uniquely identifies the object in the bucket. For example, on the Amazon S3 console , when you highlight a bucket, a list of objects in your bucket appears.
Upvotes: 0
Reputation: 2294
In AWS, here staging_path= "devel" and key = "/"+staging_path.
Upvotes: 0
Reputation: 20719
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.
Upvotes: 19
Reputation: 1419
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 )
Upvotes: 4