Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a keyName in AWS ( Amazon Web Services )?

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?

like image 754
Bianca Avatar asked Sep 28 '15 14:09

Bianca


People also ask

What is keyName in AWS?

The keyName is the "name" (=unique identifier) by which your file will be stored in the S3 bucket.

What is a keyName?

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.

What is a key pair and what is it used for?

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.

Where are key pairs used in AWS?

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 .


2 Answers

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.

like image 129
Bruce P Avatar answered Nov 16 '22 00:11

Bruce P


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 )

like image 34
Stefan De Laet Avatar answered Nov 16 '22 01:11

Stefan De Laet