How to access and upload files into folders on rackspace open cloud container using PHP? -
i using composer package 'rackspace/php-opencloud' installed with
composer require rackspace/php-opencloud
and trying upload , list of files inside folder
included autoload file , add
require 'vendor/autoload.php';
using process given on document http://docs.php-opencloud.com/en/latest/services/object-store/index.html not solution access folders inside container(recipes in case). how can upload files directory "images" , "uploads" present inside container "recipes".
$client = new opencloud\openstack('{keystoneurl}', array( 'username' => '{username}', 'password' => '{apikey}', 'tenantid' => '{tenantid}', )); $service = $client->objectstoreservice('{catalogname}', '{region}', '{urltype}');
$containers = $service->listcontainers();
foreach ($containers $container) { /** @param $container opencloud\objectstore\resource\container */ printf("container name: %s\n", $container->name); printf("number of objects within container: %d\n", $container->getobjectcount()); }
by above code, able access the list of container , can set container , can fetch list of
$containers = $service->listcontainers(); ** @param $container opencloud\objectstore\resource\container */ $container = $service->getcontainer('{containername}');
i found answer on rackspace website: https://developer.rackspace.com/docs/cloud-files/quickstart/?lang=php
and explain cannot create new container inside container can pass subdirectory pass name of object explained below:
while cannot create nested containers, cloud files support subdirectories, or subfolders. objects uploaded subdirectory through special naming convention, including subdirectory path in object name, separating path segments forward slash character /.
for example, if want relative url of object /images/kittens/thumbnails/kitty.png, upload object container using relative path object name
$object = $container->uploadobject('{subdirectories}/{object_name}', $handle);
Comments
Post a Comment