[Music]
hi this is Shahab with Amazon Web
Services in this section we are going to
take a look at how to use Amazon simple
cloud storage service or s3 your dotnet
application let's take a look at some
characteristics of Amazon s3 Amazon s3
is a highly secure durable and scalable
object storage an object can be of any
kind such as text video photo or another
binary format Amazon s3 uses buckets to
keep the data the bucket name must be
unique across Amazon s3 also a bucket is
associated with a region when you want
to choose a region you should consider
factors such as latency cost and
regulatory of requirements also there is
a caveat buckets that have a period in
the bucket name can cause certificate
exceptions when accessed with HTTP base
URLs now let's take a look at s3 objects
an object is identified by unique key
you must specify an object key to upload
and retrieve it an object keys encoded
using utf-8 encoding and the key has a
maximum length of 1,024 bytes also you
can use alphanumeric characters and some
special characters such as forward slash
in the naming an object is associated
with system defined metadata and
user-defined metadata system defined
metadata includes information such as
object creation date size and md5 digest
now let's take a look at some key points
all objects and buckets are private by
default pre-signed urls are useful if
you want your user to be able to upload
a specific object to your bucket without
being required to have a SS security
credentials or permissions also SSL
encrypted endpoints are supported so you
can encrypt the data at transition for
the data at rest you can use client-side
and servers
encryption Amazon s3 encrypts your data
at the object level as it writes it to
disk in its data centers and decrypts it
for you when you access it before
switching to the demo let's take a look
at some operations on objects that s3
supports there is a full list of api's
that you can find at a URL at the bottom
of the screen as an example s3 supports
put get delete and restore operations
you can upload or copy objects up to
five gigabyte in a single put operation
for larger objects up to five terabytes
you must use the multi-part upload API
and you should consider using multi-part
upload for objects bigger than hundred
megabyte also you can retrieve the whole
objects or part of it using a get
operation and using delete you can
delete one or more objects now let's
take a look at how to use the s3 api's
in a dotnet application using visual
studio in your Microsoft Visual Studio
you should be able to see the Amazon s3
tab in the AWS Explorer window you can
expand it and you can see the list of
pockets you already have created in your
account you can also right-click and
create a new bucket let me show you how
to use Amazon s3 api's in a dotnet
application for this purpose go to file
new project under visual c-sharp
aw samples storage you should be able to
couple of it be able to see a couple of
examples for Amazon s3 let's click on
AWS s3 sample together started with
let's create okay
and in this screen you can choose the
DVD profile and the region that your
application is going to use click OK
under the dependencies under nougat
packages you should be able to see AWS
SDK dot s3 if you have a new project and
you are working on a new code you can
always right-click on dependencies
manage nugget packages and find AWS SDK
at s3 and click on it and install it in
this window since it's already installed
I can either uninstall or update it
let's close this one and go to program
that CS which is the start point of our
console application into program dot C s
as you can see it's using Amazon dot s3
and Amazon that s3 that model libraries
these are the two main libraries that
you need to use when you are dealing
with s3 in order to use the s3 api's the
first thing you need to do is to use a
client this client should be of type
Amazon s3 client in this demo what we
are going to do we are going to list by
a current buckets that I have create a
new bucket write an object to a bucket
reading an object deleting an object and
list the objects at the end let's take a
look at how listing buckets works click
on it and go to implementation to list
the buckets you need to call the least
buckets operation on the client and the
response will have a list of pockets and
you can actually go through them and in
this scenario we can write the name of
the bucket names also in the response of
every API call to s3 you can catch the
Amazon s3 exception that can tell you
hey if there is invalid access key or
security or if there is another kind of
error let's see how to actually create a
bucket now in order to create a bucket
what you need to do you need a crate
bucket request or put bucket request in
the foot pocket request the only thing
you need to provide is a bucket name
this bucket name should be a unique but
a unique buttock bucket name for the
purpose of this application we need to
send this back
name let me actually create a new bucket
name and call it a ws dotnet learning
pass buckets one and I need to also
create a key name as well and for that
key name I will just call it key one so
we saw how to create a bucket let's go
to the next step and let's try to write
an object to the bucket let's go to
implementation to write an object into a
bucket you need to have a put object
request in the put object request you
need to provide a Content body the
bucket name and a key name the bucket
name and key name are what I described
above
after that you can call the put object
and the client and pass the request and
you can upload this object to the bucket
in your s3 account now let's take a
quick look at the next step which is
reading an object to read an object from
s3 you need to provide a gate object
request the request should have a bucket
name and key name after you have created
the request you can call the get object
and the request or the client and get
the response as mentioned before you can
always like catch the exception that can
be very descriptive to you and tell you
if there is any issue at the end we will
delete the object and then list the
existing objects so let's take a look at
how to delete an object let's go to
implementation to delete an object from
history you actually need to create a
delayed object request which has
the bucket name and key name and the
only thing you need to do is call the
delete object operation under request
and let's list the current objects right
click go to implementation to list all
the objects you just need to provide the
bucket name for the list object requests
and then you can call this request you
can pass it to list objects call and
this request as an argument to that and
call it for the client the response will
have the list of objects that in this
scenario we are just printing to the
console so this is how you can use the
history API in your dotnet application
let's run it and see what happens
it leads all the buckets these are the
buckets that I had previously now it
created a bucket right an object read at
the object the objects title is the
title this is what we said in the code
then it deletes the object and lists all
the objects which means nothing is left
so I just did show you how to use the s3
api's using a dotnet application in your
visual studio if you need more examples
for example on the transfer utility you
can always go to file new project and
under visual c-sharp
aw sample and storage you can follow
more examples including the transfer
utility in this video we went over how
to use Amazon s3 in your dotnet
application thanks for watching
[Music]