I'm trying to upload my files from the server to the CDN by using codeigniter and the cloudmanic-storage library. The functions for creating/listing containers work, but the one for adding files to the container does not.
I have no idea what is wrong with it or how to fix this issues, so if anyone has come along this problem it will be great to share some knowledge :)
$container = 'cm-storage-' . time();
echo '<h1>Create test container.</h1>';
$this->storage->create_container($container, 'private');
echo "New container: <b>$container</b><br /><br />";
echo '<hr />';
$file = "_data/articlepics/big_".$config['file_name'];
$this->storage->upload_file($container, $file, 'test01.jpg');
I'm sure that the file that I'm trying to upload exists, the problem also persists when i try it out with the example controller. It just doesn't want to upload the files to the CDN for some reason.
Codeigniter ver.2.0.2 Latest cloudmanic-storage from github
It seems that the type hasn't been defined and the guess function has trouble guessing what the file is.
What I did is to sort out the files when uploading/resizing the files in the controller and then (after i know the extension) just add the file type to the rackspace_rc_driver.php
function upload_file($cont, $path, $name, $type = NULL, $acl = 'private', $metadata = array())
{
$type="image/jpeg";
$my_container = $this->_conn->get_container($cont);
// move local file to server
$my_object = $my_container->create_object($name);
// If we pass in a type we don't try to guess the type.
if(! is_null($type))
{
$my_object->content_type = $type;
}
//echo $path;die();
$my_object->load_from_filename($path);
return ($my_object->container->cdn_enabled) ? $my_object->container->cdn_uri . '/' . $my_object->name : $my_object->name;
}
Hope this helps someone else.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.