Coder Social home page Coder Social logo

Example for DSM about synology HOT 4 CLOSED

zzarbi avatar zzarbi commented on August 15, 2024
Example for DSM

from synology.

Comments (4)

zzarbi avatar zzarbi commented on August 15, 2024

Hi,

I just tried it and it seems fine to me. I tried getInfo with AudioStation and DownloadStation.
First how are you running the script? Through you're browser or via command line?

Then I'm guessing the autoload might be the problem, I'm using "include" instead of "require" which might just throw a notice, which you might not see depending on your PHP settings. Try the following code and check if the new include path looks ok, meaning are all the "/" look like "/" and not "". Also here I'm using require instead of include and this will throw a fatal error if it's not working:

echo 'Include_path = '.get_include_path().PHP_EOL;
echo 'path_separator = '.PATH_SEPARATOR.PHP_EOL;
set_include_path(dirname(__FILE__).'/library'.PATH_SEPARATOR.get_include_path());
echo 'New Include_path = '.get_include_path().PHP_EOL.PHP_EOL;

function __autoload($class_name) {
    $path = str_replace('_', DIRECTORY_SEPARATOR, $class_name);
    echo 'Loading: '.$class_name.' => '.$path.'.php'.PHP_EOL;
    require($path . '.php');
}
$synology = new Synology_DownloadStation_Api('192.168.10.5', 5000, 'http', 1);
echo 'Great'.PHP_EOL;

My output look like that:

Include_path = .:
path_separator = :
New Include_path = /Users/zzarbi/pool/synology/library:.:

Loading: Synology_DownloadStation_Api => Synology/DownloadStation/Api.php
Loading: Synology_Api_Authenticate => Synology/Api/Authenticate.php
Loading: Synology_Abstract => Synology/Abstract.php
Loading: Synology_Api => Synology/Api.php
Great

from synology.

Bojhan avatar Bojhan commented on August 15, 2024

Wow, thanks for your timely response! I tried it and, figured out where my error was. Very helpful!

I think I slightly misunderstood the purpose of this project. I imagined it provided a implementation of the FileStation API, something I haven't seen anywhere else. My goal is retrieve all the files in a folder, list them on the page (browser) and allow users to download the files (save as). Do you expect to still add this feature?

I have been trying to implement a new API using your framework, but so far been unsuccessful.

from synology.

zzarbi avatar zzarbi commented on August 15, 2024

Hi,

I just implement just that (717804e).
With the last code you can get a list of shares for FileStation:

$synology = new Synology_FileStation_Api('192.168.10.5', 5000, 'http', 1);
$synology->activateDebug();
$synology->connect('admin', 'xxx');
print_r($synology->getShares());

Get a list of files:

print_r($synology->getList('/home'));

And download one file:

// need to disable debug
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="test.txt"'); //<<< Note the " " surrounding the file name
header('Content-Transfer-Encoding: binary');
header('Connection: Keep-Alive');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
echo $synology->download('/home/text.txt');

This should work in a browser, altho i didnt test it. You can continue the implementation if you want using this PDF (http://ukdl.synology.com/download/Document/DeveloperGuide/Synology_File_Station_API_Guide.pdf)

from synology.

Bojhan avatar Bojhan commented on August 15, 2024

I can confirm that it works beautifully. I simply use the function to do the following:

foreach ($listing->files as $file) {
$file->name;
$file->path;
}

It probally makes sense to add this to your Read.me and you could also trow it in the example.

from synology.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.