Pergunta

I'm using Dropbox Ruby SDK, now I want get a full length share url of folder instead of the short url method shares(path) returns. But I couldn't find a way to pass query parameter 'short_url=false'( found on core API) with the method, since it only accepts one argument which is the path to share.

The reason I want the full length url is that I need to provide user a direct link to download the files( by adding 'dl=1'to the full url).

Any suggestion is appreciated.

Foi útil?

Solução

It doesn't look like the Ruby library currently exposes this. But the source code is here: https://github.com/dropbox/dropbox-sdk-ruby/blob/master/lib/dropbox_sdk.rb#L1222-L1225. If you're up for it, please submit a pull request to add this to the SDK.

In the meantime, here's standalone code to do this:

def long_share_url(access_token, path)
    client = DropboxClient.new(access_token)
    session = DropboxOAuth2Session.new(access_token, nil)
    response = session.do_get "/shares/auto/#{client.format_path(path)}", {"short_url"=>false}
    Dropbox::parse_response(response)
end
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top