Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

listFiles #27

Closed
epsa-dev opened this issue Feb 15, 2019 · 3 comments
Closed

listFiles #27

epsa-dev opened this issue Feb 15, 2019 · 3 comments

Comments

@epsa-dev
Copy link

$fileList = $client->listFiles([ 'BucketId' => '6182a9b37d82f0206b8f0233' ]);
print_r($fileList);

BackblazeB2\File Object ( [id:protected] => 4_z6182a9b37d82f0206b8f061b_f100636c8f41465a9_d20190215_m224636_c002_v0001111_t0024 [name:protected] => cosas1.txt [hash:protected] => [size:protected] => 11 [type:protected] => [info:protected] => [bucketId:protected] => [action:protected] => [uploadTimestamp:protected] => )

How use json_encode($fileList); ? 😢 😭

@JoachimThomas
Copy link

JoachimThomas commented Feb 22, 2019

Hi!
You can change the protected to public in/vendor/gliterd/backblaze-b2/src/File.php or grab the response before File.php is used in Client.php
I changed the response of $client->listFiles($bucketId)
To avoid "protected" I added to vendor/gliterd/backblaze-b2/src/Client.php at line 358:
foreach ($response['files'] as $file) {
$filesArray[] = ['fileId'=>$file['fileId'],'fileName'=>$file['fileName'],'fileSize'=>$file['size'],'type'=>$file['contentType']];
header("Content-Type: application/json");
$filesArray=json_encode($filesArray);
global $responseArray[]=$filesArray;
So I can use one JSON object per bucket with all file-infos unprotected...
I store these "Bucket/File-info jsons($fileArray) in a global "response-array" and echo it instead of the regular $files.
In the Ajax function(response) i decode the response until I get the wanted Infos unprotected
Hope it helps...
Joe

@mhetreramesh
Copy link
Member

I don't understand whats the problem here, could you explain a bit more?

@JoachimThomas
Copy link

Hi !
epsa-dev asked how to use the response to $fileList = $client->listFiles.
All Items in the response are protected because the original response from b2 is transformed to
File.php, so no way to use them. Thats all.
I don't understand why the file.php has protected variables.
Joe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants