Giter Site home page Giter Site logo

p5-webservice-dropbox's People

Contributors

dstroma avatar gfx avatar rosti avatar s-aska avatar softwrx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

p5-webservice-dropbox's Issues

/2/sharing APIv2 call missing from version 2.05

Hi,

I think the sharing APIv2 call that replaces the /shares APIv1 call is not available in v2.05 of the Perl module. See https://www.dropbox.com/developers/documentation/http/documentation#sharing
More specifically I am interested in this call: /2/sharing/get_shared_link_file
(https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_file) to retrieve a URL for a file I have just uploaded.
Currently there is no possibility in the Perl APIv2 implementation to retrieve a URL for a file that was just uploaded.
It looks like none of the calls under /2/sharing are implemented in module version 2.05.

I fiddled around with the module a little bit, and I implemented a "working" version with this patch:

hostname:~ root# diff -u /Library/Perl/5.18/WebService/Dropbox/Files.pm.original /Library/Perl/5.18/WebService/Dropbox/Files.pm
--- /Library/Perl/5.18/WebService/Dropbox/Files.pm.original 2016-10-02 12:54:59.000000000 +0200
+++ /Library/Perl/5.18/WebService/Dropbox/Files.pm  2016-10-02 12:52:10.000000000 +0200
@@ -245,4 +245,20 @@
     });
 }

+# https://www.dropbox.com/developers/documentation/http/documentation#sharing
+# /2/sharing/create_shared_link_with_settings
+sub sharing_create_shared_link_with_settings {
+    my ($self, $path, $optional_params) = @_;
+
+    my $params = {
+        path => $path,
+   %{ $optional_params || {} },
+    };
+
+    $self->api({
+   url => 'https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings',
+   params => $params,
+    });
+}
+
 1;

Which allows me to use this Perl call:

                $data = $dropbox->sharing_create_shared_link_with_settings($stripped_article_out_pdf) or do {
. . .

Could you please implement this functionality one way or another. The above code is only "proof-of-concept'...

Best regards!

podもっと

ドキュメントが足りないので書き足す。

files() returning 200 response with a JSON error body

I'm downloading files from a Dropbox app like:

my $fh_get = IO::File->new("$dir/$name", '>');
$dropbox->files($name, $fh_get) or die $dropbox->error;

It completes without error, but (due to some failure on my part, I'm sure) the contents of the file is:

{"error": "Given request root of \"dropbox\" but app is an App Folder app."}

It looks like we got a 200 response, but the body is a JSON error object. No $dropbox->error is set, though there is definitely an error.

60行目の typo

no_docode_json は no_decode_json ではないでしょうか?

    no_docode_json => $args->{no_docode_json} || 0,

使いやすくて助かります。

How to suppress error messages from WebService::Dropbox?

I need handle errors by myself.
I test some file exists or not exists calling get_matadata in particularly
2022-06-14T15:57:49 [WebService::Dropbox] [ERROR] https://api.dropboxapi.com/2/files/get_metadata {"path":"/files/q/4.txt"} -> [409] {"error_summary": "path/not_found/...", "error": {".tag": "path", "path": {".tag": "not_found"}}} at /usr/local/share/perl5/WebService/Dropbox.pm line 184.

I've solved this like that:
my $meta = eval { local $SIG{__WARN__} = sub {}; $dropbox->get_metadata($file); };
But maybe exists a more eligant way...

Bug in sample code

Hello,

I love your WebService::Dropbox, however there's a small bug in your sample code:
The $box variable should be $dropbox.

Kind regards,

files_put() corrupts unicode files

WebService::Dropbox works fine with ansii files, but some files with special unicode strings are uploaded incorrectly. I'm using LWP backend, not Furl::Net.

Here is an example scrip showing the problem:

#!/usr/bin/perl

use strict;
use warnings FATAL => 'all';
use utf8;
use open qw(:std :utf8);

use WebService::Dropbox;

my $dropbox = WebService::Dropbox->new({
    key => '...',
    secret => '...',
});

$dropbox->access_token('...');
$dropbox->access_secret('...');

$dropbox->root('sandbox');

my $content = "f\nтст";

open(my $fh, "<:encoding(UTF-8)", \$content)
    or die "can't open UTF-8 encoded filename: $!";

$dropbox->files_put('file', $fh) or die $dropbox->error();

After I run it I get file with the name 'file' in my dropbox app folder. But the content of the file is not what I expect.

I expect it to be:

$ cat file
f
тст
$ hexdump file
0000000 0a66 82d1 81d1 82d1 000a
0000009

But in fact I get:

$ cat file
f
т
[0;32m$ hexdump file
0000000 0a66 82d1 66d1 d10a
0000008

Verbosity polluting logs

Hi,

is it possible remove this part or make it configurable?

warn sprintf("%s [WebService::Dropbox] [%s] %s %s -> [%s] %s",
$time,
$level,
$req->uri,
( $params ? $JSON->encode($params) : '-' ),
$res->code,
( $res_json || $decoded_content ),
);

While using the module with, for example, mod_perl, it pollutes the apache error log with warnings even if VERBOSE == 0. Additionally it may leak the Dropbox secret to the log.

Turning verbosity on leads to a crash for me:
Can't locate object method "path" via package "https://content.dropboxapi.com/2/files/download" (perhaps you forgot to load "https://content.dropboxapi.com/2/files/download"?) at /usr/local/share/perl/5.18.2/WebService/Dropbox.pm line 162.

Using version 2.05.

download() doesn't close file handle when sent a path

It looks as though the download() sub accepts a file path as its $output argument and if it does it opens the file, but I don't see a close() anywhere in the code. I'm not sure how to close the file since the filehandle created by the module isn't exposed anywhere.

Yeah, I can just use a filehandle instead, but I shouldn't have to if it takes a path..

OAuth 2.0

Is it possible to add OAuth 2.0 in to your interface?

thanks!

Do we need a way to get file url ?

the "files" method can download file, but sometimes we need know files url,
eg. html5 audio src file.
so I think we need a method to get files url, what do you think? :-)

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.