Giter VIP home page Giter VIP logo

synology's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

synology's Issues

Issue with Login API?

Following the README, can you help describe where this test scenario has gone awry?

https://github.com/mitch-b/synology-forbidden-error-test

I've created an ASP.NET Core Web project that tries to connect to a Synology server configured in the appsettings.json, and configured / executed in Startup.cs for demo purposes.

Even if I attempt with valid credentials, I'm getting a Forbidden 403 error. I'm on DSM 6.1.5-15254 Update 1. I tried this on an account without two factor authentication enabled, but I also tried with another account sending OtpCode as well. Still no success.

Thanks for any advice!

Example Code Crashes With Autofac Exception

When trying to run your example code I get an exception on the line:
var resInfo = syno.Api().Info().GetInfo();

The exception says: DependencyResolutionException

None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Synology.Api.Info.InfoRequest' can be invoked with the available services and parameters:
Cannot resolve parameter 'Synology.Classes.SynologyApi api' of constructor 'Void .ctor(SynologyApi)'.

FileStation().CopyMove().StartAsync() only moves and can move when there are no brackets from URL

While debugging the StartAsync extension from CopyMove() method sending the StartParamters it would only move a file if I caught the 'start' method and removed any brackets in the URL. When testing with a single files to copy/move (remove_src: true/false) the process would only move. Setting remove_src: false would always result in a 'move'.

Note: The share name is a guid. Couldn't think of a name for testing and is not a weird glitch.

Directory Tree for '/8c47db36-cce9-4fff-b4b2-a5df3a6a' share:

  • recycle
  • Folder A
    • example.txt
  • root.txt

Workaround:

SynologyConnectionExtension.cs: Line 108

Addition starting after line 110:

if (method.Equals("start"))
                url = url.Replace("[", "").Replace("]", "");

Code Executing StartAsync(<StartParamters>):

[HttpPost]
[Route("CopyMove")]
public async Task<IActionResult> CopyMove([FromBody] CopyMoveParams.StartParameters parameters)
{
    ResultData<CopyMoveResults.IStartResult> start = new ResultData<CopyMoveResults.IStartResult>();

    if (parameters.Path != null)
    {
        if (parameters.Path.Count() == 1)
        {
            using (var syno = _serviceProvider.GetService<ISynologyConnection>())
            {
                var login = await syno.Api().Auth().LoginAsync();

                start = await syno.FileStation().CopyMove().StartAsync(parameters);

                var logout = await syno.Api().Auth().LogoutAsync();
            }

            return Json(start);
        }
        else
        {
            return Json(new { Success = false, Error = "Only one copy/move instance is supported at this time." });
        }
    }
    else
    {
        return Json(start);
    }
}

Thanks,

-- Lincoln

[BUG] encode query parameters

Currently, the query parameters of the request was not be encoded, this may cause some bug if any parameter contains special chars like &, or #, etc.

When I create a download task, I have to manually encode the magnet link:

ServiceProvider.GetService<ISynologyConnection>()
    .DownloadStation()
    .Task()
    .CreateAsync(new TaskCreateParameters{ Uri = System.Web.HttpUtility.UrlEncode(url) });

FileStation().Rename().RenameAync() only works when there is one item to rename and brackets removed from URL

While debugging the RenameAsync extension sending the RenameParamters it would only rename a file/directory if I caught the 'rename' method and removed any brackets in the URL. When testing with multiple files/directories to rename I would get the 408 error (No such file or directory).

To add there seems to be an additional issue when you do not set a additional parameter. The below work around removes a zero addition parameter if there are no additional parameters.

Note: The share name is a guid. Couldn't think of a name for testing and is not a weird glitch.

Directory Tree for '/8c47db36-cce9-4fff-b4b2-a5df3a6a' share:

  • recycle
  • Folder A
    • example.txt
  • example.txt

Workaround:

SynologyConnectionExtension.cs: Line 108

Addition starting after line 110:

if (method.Equals("rename"))
                url = url.Replace("&additional=[0]", "").Replace("[", "").Replace("]", "");

GenericGetDataFromApiAsync var json raw output when trying multiple paths with workaround:

URL:

entry.cgi?path=/8c47db36-cce9-4fff-b4b2-a5df3a6a/example.txt,/8c47db36-cce9-4fff-b4b2-a5df3a6a/Folder A&name=test.txt,Folder B&additional=real_path&_sid=<MySID>&api=SYNO.FileStation.Rename&version=2&method=rename

Output:

{
    "error": {
        "code": 1200,
        "errors": [
            {
                "code": 408,
                "path": "/8c47db36-cce9-4fff-b4b2-a5df3a6a/example.txt,/8c47db36-cce9-4fff-b4b2-a5df3a6a/Folder A"
            }
        ]
    },
    "success": false
}

Code Executing RenameAsync(<RenameParamters>):

[HttpPost]
[Route("Rename")]
public async Task<IActionResult> Rename([FromBody] RenameParameters parameters)
{
    ResultData<RenameResult.IFileResult> renamed = new ResultData<RenameResult.IFileResult>();

    if (parameters.Path != null && parameters.Name != null)
    {
        if (parameters.Additional == 0)
            parameters.Additional = RenameAdditional.RealPath;

        using (var syno = _serviceProvider.GetService<ISynologyConnection>())
        {

            var login = await syno.Api().Auth().LoginAsync();

            renamed = await syno.FileStation().Rename().RenameAsync(parameters);

            var logout = await syno.Api().Auth().LogoutAsync();
        }
    }

    return Json(renamed);
}

Closing:

This is an awesome code base for working with the Synology api! Been learning A TON just looking through the code. I hope the above reproduction and workaround is helpful to fix/help me. I tried figuring out how to fix this and do a pull request, but to be honest the code base is more sophisticated than I am capable of. The workaround is all I could come up with.

Thanks,

-- Lincoln

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.