Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-06-13
5
Medium Priority
?
1,488 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 2000 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the wake of AWS' S3 outage, we want to discuss the importance of storage and data diversification in the event of a hack, crash, or system disruption. We spoke with Experts Exchange’s COO Gene Richardson for a deeper understanding.
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
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…
Suggested Courses

971 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