between 2 aws s3 buckets. I'm using the s3 php class from undesigned
(http://undesigned.org.za/2007/10/22/amazon-s3-php-class), which works
just fine in any other operations.
Right now im trying to move 2 files, whose filenames are (w/o
extensions) "1" and "2", from "sourcebucket" to "targetbucket".
Through the s3 class one is able to specify the filename, of the
copied file, in the target bucket.
What I want to do is use the "id" field of my model (set as char(36))
as the filename, but for some reason that i cant understand i'm not
able to do that..
Below is the afterSave() callback in my model with which im trying to
implement this:
function afterSave($created){
if($created){
$imported = App::import('Vendor','s3');
$accs3 = new S3("xxxxxx","xxxxx",0);
$bucket1 = $accs3->getBucket("sourcebucket");
foreach ($bucket1 as $key => $conts){
$keynum = intval($key);
if ($keynum == $this->position){
$cp = $accs3->copyObject("sourcebucket",
$key,"targetbucket",$this->id);
}
}
}
}
Where $key is the filename in the $bucket1 array (thats the way the s3
php class returns it) and $this->position is the "position" field in
my model.
Finally im using intval() since (to my knowledge) $key is the filename
string and $this->position is an integer.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment