json - Downloading files using google-api-php-client -


i'm having issue trying download file google cloud storage using php client found @ https://code.google.com/p/google-api-php-client/

i have authenticated myself ok , using following code can return object contains link file

$this->storageservice = new google_storageservice($this->client); $this->objects = $this->storageservice->objects;  $options = array(     'prefix' => 'report_name_2013-07-01' ); $bucket_contents = $this->objects->listobjects($bucket, $options); 

the response like...

{   "kind": "storage#object",  "id": "<bucket>/<report>.csv/1001",  "selflink": "https://www.googleapis.com/storage/v1beta2/b/<bucket>/o/<report>.csv",  "name": "<report>.csv",  "bucket": "<bucket>",  "generation": "1001",  "metageneration": "1",  "contenttype": "application/csv",  "updated": "2013-07-22t10:21:08.811z",  "size": "806",  "md5hash": "wt01i....",  "medialink": "https://www.googleapis.com/storage/v1beta2/b/<bucket>/o/<report>.csv?generation=1001&alt=media",  "owner": {   "entity": "user-00b........",   "entityid": "00b490......."  },  "crc32c": "8y........",  "etag": "cpjz.........." } 

but how go downloading file using google php client...i can't use file_get_contents has no knowledge of authentication details. best thing have found uses google_client response contains meta data , no object/file content

$request = new google_httprequest($object['selflink']); $response = $this->client->getio()->authenticatedrequest($request); 

old question, got me looking in right direction. selflink link metadata request, need medialink actual object data, , it's getauth rather getio.

this script output file contents (given have initialised $client object) :

$service = new google_service_storage($client); $object = $service->objects->get('bucketname', 'objectname'); $request = new google_http_request($object->getmedialink()); $response = $client->getauth()->authenticatedrequest($request); echo $response->getresponsebody(); 

Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -