|
|
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
|
|
|
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.
|
|
|
Rank: Newbie
Groups: Registered
Joined: 10/10/2011 Posts: 2
|
Thanks, Chris...that worked great.
|
|
|
|
Guest |