Closed Bojhan closed 10 years ago
Hi,
I'm not sure what you asking, are you unable to access the additional data field? You can access them with the following code:
$result = $synology->getList('/home', 25, 0, 'name', 'asc', '', 'all', true);
foreach($result->files as $file){
echo 'Name: '.$file->name.PHP_EOL;
echo 'Path: '.$file->path.PHP_EOL;
echo 'atime: '.$file->additional->time->atime.PHP_EOL;
echo 'crtime: '.$file->additional->time->crtime.PHP_EOL;
echo 'ctime: '.$file->additional->time->ctime.PHP_EOL;
echo 'mtime: '.$file->additional->time->mtime.PHP_EOL.PHP_EOL;
}
Now if you want to filter the result based on any additional field (including time), the FileStation API doesn't allow that. You can only retrieve additional parameter, you cannot use them to filter result.
FileStation has a search API that I didn't implement yet, that can search for range of date on mtime, crtime and atime. However it's a bit complicated, you have to "start" a search with one call to the API, then you can poll the result with a second call, but the search might not be 100% done so you will have to poll a gain. Then you can stop the search and you have to clean the search API at some point. All of that seems a bit complicated for just a filter by date.
In your case I would sort by date to get the recent files, filter the one you need, then re sort them by name in PHP. I'm guessing this would be the best case scenario.
Ah, yeah this is the work around that I implemented as well. I looked into the Search API but as you mentioned it is quite inefficient way of doing it. It is smarter for me to just occasionally purge the number of files in this directory.
I will look into the performance of both approaches. If its too much, I will just put it into a file and cache it. I think its rather silly restriction of Synology its API, I will get in touch with them to see if they might consider adding support for this.
I am going to close this issue, since the issue does not originate from this api.
Hi,
I am trying to acces the data in the 'additional' => $additional' array. In order to filter my list of files only to certain creation dates (crtime) (e.g. I only want to show the files created on 5 December 2014). According to the API docs this should be possible, when printing a raw print_r($synology->getList('/recordings')); with additional on true - it is shown in the raw dump.
However it is not directly accessible as an object. Doing something like $file->additional['crtime]'. Does not render any results. I am not sure if this is a bug, or whether its because this still needs to be fully implemented.
From the API docs, time is broken down like:
This value is part of the additional parameter.
I have been trying to work around it, but thats far les elegant. Essentially you would want to only load the files, with a certain creation date (or a range). Rather than loading all the files, and iterating over them. To give you an idea I have about 5000 files I have to iterate over. It looks like you can do this with file type, owner, etc. Just not with these additional values.