Tag: dropbox api

Dropbox API – 文件读取和上传node.js

我正在使用dropbox API从node.js文件结构读取文件,然后将该file upload到保pipe箱文件夹中。 文件被上传,但是其上传的文件的大小为0字节 var path = require("path"); var temp_dir = path.join(process.cwd(), 'pdf/'); if (!fs.existsSync(temp_dir)) fs.mkdirSync(temp_dir); fs.readFile(temp_dir + 'report.pdf', function read(err, data) { if (err) { throw err; } fileupload(data); }); file upload代码: function fileupload(name, content) { request.put('https://api-content.dropbox.com/1/files_put/auto/my_reports/report.pdf', { headers: { Authorization: 'TOKEN HERE', 'Content-Type': 'application/pdf' }, body: content }, function optionalCallback(err, httpResponse, bodymsg) { […]

使用API​​访问我们公司内的特定Dropbox用户的文件夹?

在我的工作中,我们有一个团队的Dropbox帐户,我们都有我们自己的公司Dropbox帐户,用户名/电子邮件如* .domain.com。 我已经分配了这个任务来创build一个漂亮的网页界面来存储在我们的devise师的Dropbox文件夹中的某些资产select。 其任务是构build一个Node JS应用程序,并使用Dropbox API读取这些文件,以便为该devise器的Dropbox文件夹中的文件build立良好的界面,并执行其他一些很酷的事情。 使用公共查看或共享Dropbox允许的特定文件夹是不够的。 我们需要自定义的东西,它需要真正使用API​​来完全控制。 为什么我似乎无法入门,这让我感到困惑的事情是设置NodeJS的API访问权限,让我访问该devise器的文件夹。 我不是说我需要什么代码,而只是一步一步介入。 我似乎无法包装我的头,有应用程序,将访问该公司用户的Dropbox文件夹。 我开始使用Node-dbox SDK从NodeJS访问Dropbox API,并在README中混淆了他们的身份validation,但stream程似乎并不正确? 该API似乎基于允许访问应用程序,不得不去外部应用程序等,但这似乎不正确的这种情况下? 我知道哪个特定用户的Dropbox我也想访问,我只想要应用程序来访问它…这是所有值得信赖的,因为它在公司内部。 这样做的步骤是什么? 我真的很难过

你如何将用户redirect到node.js中的另一个链接?

我正在向dropbox发送请求以获取request_token。 一旦我得到了request_token,我需要redirect到“authorize_url”:“ https://www.dropbox.com/1/oauth/authorize?oauth_token=H4bYgmttvjA1S332Zv ”得到access_token。 在JavaScript中我知道我们可以使用window.locationredirecturl.but在node.js我该怎么做呢? exports.dropboxRequestToken = function(req, res){ var app = dbox.app({ "app_key": secrets.dropbox.key, "app_secret": secrets.dropbox.secret, "root": secrets.dropbox.root }); app.requesttoken(function(status, request_token){ //console.log("status: " + status); if(status == 200){ req.session.dropbox = { request_token: request_token, app_info: { app_key: req.param('app_key'), app_secret: req.param('app_secret'), root: req.param('root') } }; //I need to reidrect user to this URL https://www.dropbox.com/1/oauth/authorize?oauth_token=H4bYgmttvjA1S332Zv } }); […]

关于任意数据

什么是任意数据? 我在这里find它https://www.dropbox.com/developers/core/docs#oa2-authorize state Up to 200 bytes of arbitrary data that will be passed back to your redirect URI. This parameter should be used to protect against cross-site request forgery (CSRF). See Sections 4.4.1.8 and 4.4.2.5 of the OAuth 2.0 threat model spec. 那么我为state发送什么types的价值呢? 我正在使用nodejs。

Dropbox token API在Node.js中返回“Missing client credentials”

我尝试在普通的Node.js中使用Dropbox Core API。 它被编程为: 用户打开授权页面并获取代码。 用户将代码input到应用程序。 应用程序将其发送到Dropbox API。 API返回令牌。 但我不能令牌和API返回错误消息“丢失的客户端凭据”。 我的代码在这里: https : //gist.github.com/ginpei/65890135d323f18207c0 关于API: https : //www.dropbox.com/developers/core/docs 我应该如何编写代码来获取令牌? 谢谢。 编辑从链接的要点添加代码: // About API: // https://www.dropbox.com/developers/core/docs#oa2-authorize // https://www.dropbox.com/developers/core/docs#oa2-token var config = require('./config.json'); // OR… // var config = { // 'appKey': 'xxxxxxxxxxxxxxx', // 'secretKey': 'xxxxxxxxxxxxxxx' // }; var readline = require('readline'); var https = require('https'); […]

从node.js上传文件到Dropbox

我正尝试从Node.js上传文件到我的保pipe箱帐户。 我已经在Dropbox开发者控制台上创build了一个应用程序,然后生成了一个访问令牌。 我正在使用下面的代码来读取并上传文件到Dropbox: app.get('/uploadfile', function (req, res) { if (req.query.error) { return res.send('ERROR ' + req.query.error + ': ' + req.query.error_description); } fs.readFile(__dirname + '/files/pictureicon.png','utf8', function read(err, data) { if (err) { throw err; } fileupload(data); }); }); function fileupload(content) { request.put('https://api-content.dropbox.com/1/files_put/auto/proposals/icon.png', { headers: { Authorization: 'Bearer TOKEN-HERE', 'Content-Type': 'image/png' }, body: content}, function optionalCallback […]

file upload通过Dropbox的Api V2

以前,我在我的networking应用程序中使用Dropbox API V1上传我的保pipe箱帐户的文件。 请注意,该应用程序只使用一个Dropbox帐户(我的)上传文件。 所以之前: 我在Dropbox开发者控制台上创build了一个应用程序 从开发者控制台生成我的令牌 将该令牌硬编码到我的服务器上,将所有file upload到我的Dropbox中的特定文件夹。 这之前工作完美,但作为Dropbox API v1已被弃用,它不再工作。 Dropbox V1代码: function fileupload(content) { request.put('https://api-content.dropbox.com/1/files_put/auto/my_reports/report.pdf', { headers: { Authorization: 'TOKEN HERE', 'Content-Type': 'application/pdf' }, body: content }, function optionalCallback(err, httpResponse, bodymsg) { if (err) { console.log(err); } else { console.log("File uploaded to dropbox successfully!"); fs.unlink(temp_dir + 'report.pdf', function(err) { if (err) throw […]

node.js dropbox OAuth

我在理解Node.js的Dropbox JS api时遇到了一些麻烦 在创buildauthDriver后,如何将客户端路由到保pipe箱访问对话框? 假设他们得到我的快递应用程序处理的路线“/ applogin”,如何将客户端传递给Dropbox? 谢谢! var Dropbox = require("dropbox"); var client = new Dropbox.client({ key: "mykey", secret: "mysecret", sandbox: true }); client.authDriver(new Dropbox.Drivers.NodeServer(8081)); //what comes next?

发送一个缓冲区给客户端下载

我从Dropbox的Node.js服务器上下载了一个Buffer。 我想发送缓冲区(或将其转换为文件并发送给客户端),并立即开始在客户端下载。 我在这里错过了什么? var client = DBoxApp.client(req.session.dbox_access_token); client.get(req.body.id, function(status, data, metadata) { // WHAT DO I DO HERE? }) 这是我的angular度(使用承诺)。 当我console.log(响应我得到一个对象,包括缓冲区)。 function(id, cloud){ return $http.post('/download/'+cloud, {id: id}).then(function(response){ console.log(response) }, function(response) { return $q.reject(response.data); }) }

如何使用dropbox.js将file upload到Dropbox?

原版的 我有问题使用官方dropbox.js从Node.js上传文件(图片)到Dropbox。 我想上传我在另一台服务器上的图片。 例如,使用dropbpox图标(www.dropbox.com/static/images/new_logo.png)。 client.writeFile(file, 'www.dropbox.com/static/images/new_logo.png', function(error, stat) { if (error) { return es.send(error.status); // Something went wrong. } res.send("File saved as revision " + stat.revisionTag); }); 我知道这只是创build一个带有url的文本文件,但是我怎样才能将图片上传到Dropbox? 我也尝试使用http.get下载文件,然后将其上传到保pipe箱,但不起作用。 谢谢。 更新信息 首先,我用下面的代码从远程URL下载图像: var request = http.get(options, function(res){ var imagedata = '' res.setEncoding('binary') res.on('data', function(chunk){ imagedata += chunk }) res.on('end', function(){ console.log("Image downloaded!"); fs.writeFile(local, imagedata, 'binary', […]