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

Notification

Icon
Error

Options
Go to last post Go to first unread
Brainwrek  
#1 Posted : Monday, April 12, 2010 11:41:31 AM(UTC)
Brainwrek

Rank: Member

Groups: Member
Joined: 4/7/2010(UTC)
Posts: 12

I'm still fairly inexperienced with S3, so I'm sorry if this is covered somewhere. I haven't seen the issue addressed though...

I'm wondering if the AmazonS3Extender is capable of creating a new bucket on the fly? For example... is it possible to force the script to create and then upload to a date stamped bucket (e.g. 20100412)?

Thank you.

BTW... I'm really loving what I'm seeing with the trial version. I've implemented lots of cool customizations, and I'm surprised how you've made such a robust script so easy to use. Cheers!

Edited by user Monday, April 12, 2010 1:27:18 PM(UTC)  | Reason: Not specified

andreym  
#2 Posted : Monday, April 12, 2010 12:51:41 PM(UTC)
andreym

Rank: Advanced Member

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

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

I see the two options how it can be done. First, as you suggested, add time-stamp to the $key parameter.

index.php
Code:
$key = $destination_folder .'${filename}';

replace to
Code:
$key = $destination_folder. time() . '/' .'${filename}';

Note, we add time-stamp to the $key, but not to the $destination_folder itself, because we use $destination_folder in the gallery.php to get uploaded images.
But that way has a disadvantage. Once the page loaded it always use the same time-stamp folder to upload files. I.e. when you open the page and AmazonS3Extender will be configured (it is client javascript code):
Code:
var key = 'imageuploader/images/1271128814/${filename}'; // This path will be used until you reload the page
...
//Create Amazon S3 extender
var as3 = new AmazonS3Extender(iu);
...
 
as3.getSourceFile().setKey(key);
...
 
as3.getThumbnail1().setKey(key);
...
 
as3.getThumbnail2().setKey(key);


The second way is to change the client javascript code to reconfigure AmazonS3Extender before upload. Change the $key parameter from this
index.php
Code:
$key = $destination_folder .'${filename}';

to
Code:
$key = $destination_folder;

It will be the base path. Then change the send() function in the sendhelper.js file like this:
Code:
function send() {

    // New upload started, create new timestamp value
    var timestamp = + new Date; // get current time in the numeric format
    // And reconfigure AmazonS3Extender
    as3.getSourceFile().setKey(key + timestamp + '/${filename}');
    as3.getThumbnail1().setKey(key + timestamp + '/${filename}');
    as3.getThumbnail2().setKey(key + timestamp + '/${filename}');

    totalFilesUploaded = 0;
    uploadCount = 0;
    cancelled = false;
    var u = getImageUploader("ImageUploader1");
    //save upload list
    u.SaveUploadList(1);
    //send files
    u.Send();
}

Also, with the second solution we can place original file and thumbnail in different folders. Just set the different key for them.
Brainwrek  
#3 Posted : Monday, April 12, 2010 1:19:00 PM(UTC)
Brainwrek

Rank: Member

Groups: Member
Joined: 4/7/2010(UTC)
Posts: 12

Actually, I'm digging a little deeper into AmazonS3_Helper.php. Perhaps it would make more sense to create a new date-stamped FOLDER instead of a new BUCKET. Yes?

Either way, I'm wondering if it's possible to create the new folder automatically on the fly (as described earlier) according to the current date? (e.g. 20100412)

Perhaps this can be done with an edit to: $destination_folder = 'imageuploader/images/';

??

Thanks for looking.
Code:
/*
 * Amazon S3 samples settings. This settings required to run Amazon S3 and Amazon S3 Images samples.
 */

// Your AWSAccessKeyId
$amazon_AWSAccessKeyId = '';
// Your SecretAccessKey
$amazon_SecretAccessKey = '';
// Bucket name where to upload files. The bucket should exist in Amazon S3 service.
$amazon_Bucket = '';

// End of Amazon S3 sample settings.

// Set folder where files should be uploaded
$destination_folder = 'imageuploader/images/';
$acl = 'public-read';

Edited by user Monday, April 12, 2010 1:27:39 PM(UTC)  | Reason: Not specified

Dmitry  
#4 Posted : Monday, April 12, 2010 2:49:38 PM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,070

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
Hello,

Find the answer in the 2nd post of this thread.
Sincerely yours,
Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!
Brainwrek  
#5 Posted : Wednesday, April 14, 2010 1:30:37 AM(UTC)
Brainwrek

Rank: Member

Groups: Member
Joined: 4/7/2010(UTC)
Posts: 12

Thank you gentlemen!

I haven't tried this yet, but it looks like it should work like a charm. Applause

Edited by user Wednesday, April 14, 2010 1:31:10 AM(UTC)  | Reason: Not specified

Brainwrek  
#6 Posted : Wednesday, April 14, 2010 3:37:06 PM(UTC)
Brainwrek

Rank: Member

Groups: Member
Joined: 4/7/2010(UTC)
Posts: 12

andreym wrote:

The second way is to change the client javascript code to reconfigure AmazonS3Extender before upload. Change the $key parameter from this
index.php
Code:
$key = $destination_folder .'${filename}';

to
Code:
$key = $destination_folder;

It will be the base path. Then change the send() function in the sendhelper.js file like this:
Code:
function send() {

    // New upload started, create new timestamp value
    var timestamp = + new Date; // get current time in the numeric format
    // And reconfigure AmazonS3Extender
    as3.getSourceFile().setKey(key + timestamp + '/${filename}');
    as3.getThumbnail1().setKey(key + timestamp + '/${filename}');
    as3.getThumbnail2().setKey(key + timestamp + '/${filename}');

    totalFilesUploaded = 0;
    uploadCount = 0;
    cancelled = false;
    var u = getImageUploader("ImageUploader1");
    //save upload list
    u.SaveUploadList(1);
    //send files
    u.Send();
}

Also, with the second solution we can place original file and thumbnail in different folders. Just set the different key for them.
Yes, it looks like your second option is the better of the two. And I've tried it, but it doesn't seem to work. The uploader goes through all the motions, and it "looks" like it works, but it doesn't actually create the bucket on AS3 -- at least as far as I can tell.

To be clear... I altered the files as you recommended, uploaded two photos, and ImageUploader said that the Upload was Complete. Then I went into the bucket (with BucketExplorer). No buckets were created and no files were uploaded.

I will continue to investigate.

Edited by user Wednesday, April 14, 2010 3:50:28 PM(UTC)  | Reason: Not specified

andreym  
#7 Posted : Wednesday, April 14, 2010 7:33:09 PM(UTC)
andreym

Rank: Advanced Member

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

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

I've changed the AmazonS3Advanced demo according to the instructions from my previous post and it works for me. I attach it to this post, so check it out.
Note, that you need manually create the bucket, which you set in the $amazon_Bucket parameter. We can not create it automatically, because the buckets are unique among the all amazon s3 buckets. But the folder is not necessary to exist. Amazon S3 creates it from the key parameter automatically.
In particular, this demo upload files into the imageuploade/images/{timestamp}/ folder, where {timestamp} is different for different upload sessions.
File Attachment(s):
PHP_IUEmbed.zip (2,253kb) downloaded 8 time(s).
Brainwrek  
#8 Posted : Thursday, April 15, 2010 9:59:15 PM(UTC)
Brainwrek

Rank: Member

Groups: Member
Joined: 4/7/2010(UTC)
Posts: 12

Wow andreym. Thank you!

I really appreciate your work on this.

I did upload your zip and I can confirm that it works great out of the box.

But I've been trying to port it to my setup (using PHP instead of Java) and something is breaking it. I'm also noticing some other bothersome problems, that I can't seem to fix, so I'll probably need to hire you guys to help me out.

I'll let you know.

Dmitry  
#9 Posted : Thursday, April 15, 2010 10:22:37 PM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,070

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
Hello,

Just create a ticket if you do not want to post details of your project to the public forum.

Edited by user Thursday, April 15, 2010 10:23:18 PM(UTC)  | Reason: Not specified

Sincerely yours,
Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!
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.