-
Notifications
You must be signed in to change notification settings - Fork 0
Home
wishfoundry edited this page Oct 5, 2012
·
6 revisions
This is a Laravel Bundle for uploading and removing files from Rackspace CloudFiles.
Install cloudfiles using artisan:
php artisan bundle:install cloudfiles
Then in your application/bundles.php file, add the following line to load Resizer automatically:
return array(
'cloudfiles' => array( 'auto' => true )
);
Or without the 'auto' => true
to load it on demand:
return array(
'cloudfiles'
);
<?php
Bundle::start('cloudfiles');
$cf = Ioc::resolve('cloudfiles');
/**
* Set the container (Bucket for your AWS S3 fans)
**/
$container = $cf->get_container('my_demo_container');
/**
* $new_files becomes the new object. Set the file name
**/
$new_file = $container->create_object('my_image_file_name.jpg');
/**
* Upload an existing file to the $new_file object. This part is actually uploading to the CDN
**/
if (($saved_file = $new_file->load_from_filename('savedpics/my_image_file_name.jpg'))!== false) {
// image uploaded. do some stuff here
} else {
// error
echo 'Error uploading my_image_file_name.jpg';
}
<?php
Bundle::start('cloudfiles');
$cf = Ioc::resolve('cloudfiles');
/**
* Set the container (Bucket for your AWS S3 fans)
**/
$container = $cf->get_container('my_demo_container');
/**
* Delete the file by name from the container
**/
if ($container->delete_object('my_image_file_name.jpg'))
echo 'my_image_file_name.jpg has been deleted';
else
echo 'Error deleting my_image_file_name.jpg';