-2

I am working with an api which answers the requests with "protected" data object

like this

(
    [id:protected] => id:NYhXwGRVDzAAAAAAAAAA62
    [name:protected] => 5cf8cdd54328c.EDF
    [rev:protected] => 014a0000000150eaacf0
    [size:protected] => 25136208
    [server_modified:protected] => 2019-06-06T08:25:00Z
    [has_explicit_shared_members:protected] => 
    [data:protected] => Array
        (
            [name] => 5cf8cdd54328c.EDF
            [path_lower] => /5cf8cdd54328c.edf
            [path_display] => /5cf8cdd54328c.EDF
            [id] => id:NYhXwGRVDzAAAAAAAA125
            [client_modified] => 2019-06-06T08:25:00Z
            [server_modified] => 2019-06-06T08:25:00Z
            [rev] => 014a0000000150eaacf0
            [size] => 25136208
            [is_downloadable] => 1
            [content_hash] => 86442139304784e3b18d1d46f1b20bc48847
        )
)

I have converted the object to array with the following code

$metadata = (array)$file->getMetadata();

Array
(
    [*id] => id:NYhXwGRVDzAAAAAA44554
    [*name] => 5cf8cdd54328c.EDF
    [*rev] => 014a0000000150eaacf0
    [*size] => 25136208
    [*media_info] => 
    [*sharing_info] => 
    [*path_display] => /5cf8cdd54328c.EDF
    [*client_modified] => 2019-06-06T08:25:00Z
    [*server_modified] => 2019-06-06T08:25:00Z

    [*data] => Array
        (
            [name] => 5cf8cdd54328c.EDF
            [path_display] => /5cf8cdd54328c.EDF
            [id] => id:NYhXwGRVDzAAAAAAA23382
            [client_modified] => 2019-06-06T08:25:00Z
            [server_modified] => 2019-06-06T08:25:00Z
            [rev] => 014a0000000150eaacf0
            [size] => 25136208
            [is_downloadable] => 1
            [content_hash] => 86442139304784e3b18d1d46f1b20bc4884
        )

)

But when i try to print the value print_r($metadata['*size']);

Notice: Undefined index: *size in C:\xampp\htdocs\Proyectos\kardion\kardion\sistema\download.php on line 28

I think it will be a very easy answer but I have no idea how to do it

Wilfredo Aleman
  • 101
  • 2
  • 15

1 Answers1

1

I'm unsure where all those asterisks are coming from. I can't see them documented in any of the PHP ::getMetadata functions. Is this something you wrote yourself? I would suggest trying to remove any *s before attempting to read the index, and I suspect that's what's causing your error. Have you tried just print_r($metadata['size']);?

Tom Barden
  • 326
  • 2
  • 13
  • Ty for anwer, `print_r($metadata['size']);` Notice: Undefined index: size in C:\xampp\htdocs\Proyectos\kardion\kardion\sistema\download.php on line 28 – Wilfredo Aleman Jun 06 '19 at 09:07