Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Cloud-based technologies and services will continue to grow in popularity in 2017 thanks to the simple, scalable and cost-effective solutions they deliver. Here are three areas where cloud adoption is poised to really take off.
Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
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…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

704 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