SlickUpload
Welcome Guest Search | Active Topics | Log In | Register

Amazon S3 - Change folder? Options
jimmyd
#1 Posted : Monday, October 10, 2011 12:55:39 PM
Rank: Newbie

Groups: Registered

Joined: 10/10/2011
Posts: 2

Hey,

    I'm uploading directly to Amazon S3 with SlickUpload. I've specified my Amazon info in the web config and it works great; I've successfully uploaded to the root of my bucket. My question is: Is there a way I can change folder the file is saved in? So I could save somewhere like bucketName/myFolder/myFolder2/img.jpg, instead of just saving in bucketName/img.jpg?

Thanks,

Jim

Axosoft
#2 Posted : Tuesday, October 11, 2011 10:05:23 AM
Rank: Administration


Groups: Administrators

Joined: 7/7/2005
Posts: 1,586
Location: Scottsdale, AZ

Sure. To do this, you'll need to create your own UploadStreamProvider class that derives from the S3UploadStreamProvider class. This will allow you to override how the object names are generated. To do this:

  • Create a new class that inherits S3UploadStreamProvider
  • Add a constructor that takes one argument (UploadStreamProviderElement settings), and passes it to the base class
  • Override the GetObjectName method. Return whatever you want the name to be here. For example, you could do

    return "path/to/" + file.ClientName;
  • Change the uploadStreamProvider configuration in web.config to point to your new class. To do this, change the type attribute from "S3" to "YourNamespace.YourClassName, YourAssemblyName" (replacing with the appropriate values for your scenario). If your class is in App_Code, leave off the comma and assembly name.

Let me know if you have any questions.

jimmyd
#3 Posted : Tuesday, October 11, 2011 11:44:49 AM
Rank: Newbie

Groups: Registered

Joined: 10/10/2011
Posts: 2

Thanks, Chris...that worked great.

Users browsing this topic
Guest
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.