3

I was using rackspace and while uploading files I wasn't able to create sub directories or container for thumbnail files. The reason i am not uploading is because i want to keep the files url as {someUrl}/{fileName} and for their thumbnails i want {someUrl}/thumbnails/{fileName}. So i did this

$ActualImage = file_get_contents($fileThumbPath);
$rackspace->storeObject('VAC', $fileName, $ActualImage,$this->getMataData($extension));

This works fine but when i do this

$thumbImage = file_get_contents($fileThumbPath);
    $rackspace->storeObject('VAC/thumbnails/', $fileName, $thumbImage ,$this->getMataData($extension));

How can i upload to subdirectories

In Zend framework 1 I was doing this

require_once('Rackspace/Cloudfiles.php');
$cf = new Rackspace_Cloudfiles(user,pass);
    $cf->putObject('VAC/thumbnails/' . $fileName, $thumbfileData);

and that works fine

Started a bounty because i really needed to implement this in zend framework 2 . I have two version of an application and in order to work them both they need to save the files on the same location. This nested file saving is really need guys...

malarzm
  • 2,831
  • 2
  • 15
  • 25
Waqar Haider
  • 929
  • 10
  • 33
  • Which Rackspace library are you using to upload the files? Have you created the directory first? – aynber Jun 06 '18 at 16:48
  • `zendservice-rackspace` and i have been uploading files with older versions of `zf1` – Waqar Haider Jun 06 '18 at 16:51
  • 3
    `The primary difference between a container and these other file system concepts is that containers cannot be nested.` | `The only restrictions on container names is that they cannot contain a forward slash (/) and must be less than 256 bytes in length (please note that the length restriction applies to the name using the URL encoded format).` [src](https://framework.zend.com/manual/2.3/en/modules/zendservice.rackspace.files.html) – aynber Jun 06 '18 at 17:30

1 Answers1

0

In Rackspace containers there is no concept of sub directories, but they use virual directory system. So your file name should have sub directory structure.

Change your file name to - "/thumbnails/".$filename

$rackspace->storeObject('VAC', '/thumbnails/'.$fileName, $thumbImage ,$this->getMataData($extension));
mdeora
  • 4,152
  • 2
  • 19
  • 29