Solved

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

Posted on 2013-06-13
5
1,387 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There is no doubt that cloud is gaining importance. Many of you must have read about this technology and its growing importance. More and more organisations are embracing this technology not forgetting start-ups. The process begins by dipping …
A customer recently asked me about anti-malware and the different deployment options available for his business. Daily news about cyberattacks, zero-day vulnerabilities, and companies that suffered a security breach made him wonder if the endpoint a…
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…
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…

730 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