Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
rtmc  
#1 Posted : Monday, July 18, 2011 9:32:50 AM(UTC)
rtmc

Rank: Newbie

Groups: Member
Joined: 7/18/2011(UTC)
Posts: 4

Hi, I am researching your product, and it looks like it does exactly what I need - allow clients to perform multiple image uploads to an S3 bucket. One question - is there a way to get the filename for each image either during or after the upload? One of my requirements is that I need to store the filename(s) in the database, so I'll need to be able to access that info. I will be programming in ASP.Net (C#).

Thanks!
andreym  
#2 Posted : Monday, July 18, 2011 9:29:28 PM(UTC)
andreym

Rank: Advanced Member

Groups: Member
Joined: 6/16/2009(UTC)
Posts: 134

Was thanked: 8 time(s) in 8 post(s)
Hello!

The simplest way is, after upload to Amazon S3 completes, redirect to another page, iterate Amazon S3 bucket, and add new files to the database.
In the our ASP.NET - C# sample we have a sample code of how to get the list of the files from Amazon S3 bucket. Look at the Image Uploader 7.0.28\ASP.NET\Samples_ImageUploaderAspNet\CloudStorageDemo\AmazonS3Demo\Gallery.aspx.cs file:
Code:
AmazonS3 service = new com.amazonaws.s3.doc.AmazonS3();
DateTime dt = new DateTime(DateTime.Now.ToUniversalTime().Ticks, DateTimeKind.Utc);
dt = new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, DateTimeKind.Utc);
// Signature is concatenation of "AmazonS3" + OPERATION + Timestamp
string signature = "AmazonS3" + "ListBucket" + dt.ToString("s") + ".000Z";
// and create HMAC-SHA1 digest for concatenated string
signature = AmazonS3Helper.CreateSignature(signature, secretAccessKey);
 
// Get list of objects from Amazon S3
ListBucketResult result = service.ListBucket(bucket, _destinationFolder + "original/", null, 0, false, "/", AWSAccessKeyId, dt, true, signature, null);
 
if (result.Contents != null)
{
   // TODO: iterate through files and add to database
}
rtmc  
#3 Posted : Tuesday, July 19, 2011 5:50:46 AM(UTC)
rtmc

Rank: Newbie

Groups: Member
Joined: 7/18/2011(UTC)
Posts: 4

Thanks for the reply, but I don't know how effective that will be when there are several thousand items in the bucket. It's my understanding that a S3 bucket can't have subfolders, and if that is the case, then the bucket I am uploading to will get large in a hurry. Any other options here? Thanks again.
rtmc  
#4 Posted : Tuesday, July 19, 2011 1:08:20 PM(UTC)
rtmc

Rank: Newbie

Groups: Member
Joined: 7/18/2011(UTC)
Posts: 4

Actually, after doing some more research, it looks like you can have folders and subfolders in a bucket. I think I was looking at older documentation. So, if that is the case, I should be able to loop the folder to get the file names, as you noted. (I am assuming you can iterate a folder within a bucket, as opposed to the entire bucket?) Here's another question regarding your product - if I try to upload to a folder that does not yet exist in the bucket, will it be created and then uploaded to? Or will I need to create the folder first, then use your application to upload to it? Thanks!
andreym  
#5 Posted : Tuesday, July 19, 2011 7:26:37 PM(UTC)
andreym

Rank: Advanced Member

Groups: Member
Joined: 6/16/2009(UTC)
Posts: 134

Was thanked: 8 time(s) in 8 post(s)
Hello!

Quote:
Here's another question regarding your product - if I try to upload to a folder that does not yet exist in the bucket, will it be created and then uploaded to? Or will I need to create the folder first, then use your application to upload to it?


No, you don't need to create folder.

Here's why. In Amazon S3 terminology the all the thing after bucket name is a key for the object (file). It just looks like a file path and it is commonly used like this, but in general it is not necessary to look like this.
Here are some links that may be useful: one, two.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.