Solved

Upload file to my Amazon S3 account through my separate ASP.Net server

Posted on 2013-06-13
5
1,308 Views
Last Modified: 2014-11-12
Hello,
Before I try to do it, I'd like to know If and How can I do it…
1) I have an Amazon S3 account.
2) I have an ASP.Net Server located elsewhere (that currently stores the files locally).
I'd like to use my Amazon S3 account as a storage place for files and use it through My ASP.Net Server. I'd like to perform two main tasks:
1) Upload file from a Client Browser (hopefully directly) to Amazon S3.
2) Get a Tree List of my files at my Amazon S3 and display it at the Client Browser.
See a diagram attached below.
Questions:
1) I suppose I Must install AWS SDK for .NET (http://aws.amazon.com/sdkfornet/). Do I? or can I just add few DLL References to my ASP.Net project?
2) Can you give me some code/references to start with? But please not an "auto generated code" – I'd like to write it myself and integrate it with my existing ASP.Net code.
Thanks a lot, Aryeh.
 Flow Diagram of what I expect
0
Comment
Question by:tuchfeld
  • 4
5 Comments
 
LVL 23

Assisted Solution

by:Roopesh Reddy
Roopesh Reddy earned 500 total points
ID: 39247903
Hi,

You can directly upload the files to Amazon. Unfortunately, i don't know on sending files to Amazon. May be Amazon's SDK will help you to do that!

A blog post on uploading file - http://roopeshreddy.wordpress.com/2012/02/27/viewing-uploaded-file/

Once you get the file in to ASP.NET server, then you can push it to Amazon - http://www.cloudcomputingetc.com/2011/08/upload-files-to-amazon-s3-bucket-using.html

Hope it helps u...
0
 

Accepted Solution

by:
tuchfeld earned 0 total points
ID: 39268816
Thanx,
Actually all I needed is AWSSDK.dll (5M).
Here is a good samples code package.
And here is a code for listing directory recursively in VB.Net:
Imports Amazon
Imports Amazon.S3
Imports Amazon.S3.Model
Imports System.IO

Const bucketName As String = "***"
client As AmazonS3 = Amazon.AWSClientFactory.CreateAmazonS3Client(MY_AWS_ACCESS_KEY_ID, MY_AWS_SECRET_KEY)
List_Folder("MM/Music/Eng_man/Flat/Classics/")

Private Sub List_Folder(ByVal prefix As String)
    Dim request As New ListObjectsRequest()
    request.BucketName = bucketName
    request.WithPrefix(prefix)
    Dim response As ListObjectsResponse = client.ListObjects(request)
    For Each entry As S3Object In response.S3Objects
        Dim entry_Key As String = entry.Key
        Dim entry_Size As Long = entry.Size
        If entry_Key.EndsWith("/") AndAlso entry_Size = 0 Then
            If entry_Key <> prefix Then
                List_Folder(entry_Key)
            End If
        Else
            ResultsTextBox.Text += String.Format("{0} ({1})" & vbCrLf, entry_Key, entry_Size)
        End If
    Next
End Sub

Open in new window

And here is code for Uploading a file:
Public Sub UploadFileToS3(ByVal toWhichBucketName As String, ByVal uploadAsFileName As String, ByVal fileStream As Stream, ByVal filePermission As S3CannedACL, ByVal storageType As S3StorageClass)
    Dim client As AmazonS3 = Amazon.AWSClientFactory.CreateAmazonS3Client(MY_AWS_ACCESS_KEY_ID, MY_AWS_SECRET_KEY)
    Dim request As New PutObjectRequest()
    request.WithInputStream(fileStream)
    request.WithBucketName(toWhichBucketName)
    request.WithKey(uploadAsFileName)
    request.CannedACL = filePermission
    request.StorageClass = storageType
    client.PutObject(request)
End Sub

Open in new window

0
 

Author Comment

by:tuchfeld
ID: 39269129
I've requested that this question be closed as follows:

Accepted answer: 500 points for roopeshreddy's comment #a39247903
Assisted answer: 0 points for tuchfeld's comment #a39268816

for the following reason:

No much details in reply. but thanks anyway.
0
 

Author Comment

by:tuchfeld
ID: 39269130
opps. no need for recursive calling List_Folder(entry_Key)
just use the folders value.
0
 

Author Closing Comment

by:tuchfeld
ID: 39283761
Thanks for encouraging me to go on searching and finding the solution.
0

Featured Post

Do email signature updates give you a headache?

Do you feel like all of your time is spent managing email signatures? Too busy to visit every user’s desk to make updates? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today!

Join & Write a Comment

As a financial services provider, your business is impacted by two of the strictest federal regulations on record: the Sarbanes-Oxley Act and the Gramm-Leach-Bliley Act. Correctly implementing faxing into your organization to provide secure, real-ti…
Is your company's data protection keeping pace with virtualization? Here are 7 dynamic ways to adapt to rapid breakthroughs in technology.
This Micro Tutorial will explain how to export DynamoDB tables in Amazon Web Services.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now