我正在尝试使用Dropbox API v2上传文件.不幸的是,Dropbox API v2没有PHP库.
https://www.dropbox.com/developers/documentation/http/documentation#files-upload
这是我的代码:
$token = 'sometoken'; // oauth token
$headers = array("Authorization: Bearer ". $token,
'Dropbox-API-Arg: {"path": "/test.txt","mode": "add","autorename": true,"mute":false}',
"Content-Type: application/octet-stream");
$url = 'https://content.dropboxapi.com/2/files/upload';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
$path = './google/file.json';
$fp = fopen($path, 'rb');
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($path));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo($response.'<br/>');
echo($http_code.'<br/>');
curl_close($ch);
echo $response;
Run Code Online (Sandbox Code Playgroud)
它创建test.txt但是0字节.当我检查代码时,它读取0字节.
这是代码执行的输出:
* Trying 45.58.74.164... …Run Code Online (Sandbox Code Playgroud) 我试图立即将整个文件夹上传到Dropbox,但我似乎无法完成它是否可能?即使我在尝试上传单个文件时,我必须在Dropbox路径中精确定位文件扩展名,还有其他方法吗?我正在使用的代码
client = dropbox.client.DropboxClient(access_token)
f= open(file_path)
response = client.put_file('/pass',f )
Run Code Online (Sandbox Code Playgroud)
但它不起作用
在Dropbox SDK 2.0中,有没有办法检查文件夹是否存在?或者我们是否使用列出文件夹然后扫描列表的强力方法?
我试图在python中创建一个类,它读取dropbox的访问密钥/密码然后下载文件.密钥/秘密部分正常工作,但我似乎在识别客户端对象时遇到问题,可能是由于全局变量和局部变量的问题.我无法在其他地方找到答案.
这是我的代码的一部分:
from dropbox import client, rest, session
class GetFile(object):
def __init__(self, file1):
self.auth_user()
def auth_user(self):
APP_KEY = 'xxxxxxxxxxxxxx'
APP_SECRET = 'xxxxxxxxxxxxxx'
ACCESS_TYPE = 'dropbox'
TOKENS = 'dropbox_token.txt'
token_file = open(TOKENS)
token_key,token_secret = token_file.read().split('|')
token_file.close()
sess = session.DropboxSession(APP_KEY,APP_SECRET, ACCESS_TYPE)
sess.set_token(token_key,token_secret)
client = client.DropboxClient(sess)
base, ext = file1.split('.')
f, metadata = client.get_file_and_metadata(file1)
out = open('/%s_COPY.%s' %(base, ext), 'w')
out.write(f.read())
Run Code Online (Sandbox Code Playgroud)
这是错误:
Traceback (most recent call last):
File "access_db.py", line 30, in <module>
start = GetFile(file_name)
File "access_db.py", line 6, in __init__
self.auth_user() …Run Code Online (Sandbox Code Playgroud) 我想使用 HTTP API 重命名 Dropbox 上的文件。
根据新文档,可以移动,但不能重命名?
https://www.dropbox.com/developers/documentation/http/documentation#files-move
我还希望能够修改其他元数据,尤其是 client_modified,而无需重新上传文件。
文档是最新的,还是有其他可用的功能?
我有很多apk文件,我想用robotium为它们编写简单的测试.当我尝试在Dropbox应用程序中找到主要活动时,我遇到了一些问题.在AndroidManifest.xml中,我发现了这个:
</activity>
<provider android:name=".provider.ZipperedMediaProvider" android:exported="false" android:authorities="com.dropbox.android.ZipperedMediaProvider"></provider>
<provider android:name=".provider.CameraUploadsProvider" android:exported="false" android:authorities="com.dropbox.android.CameraUploadsProvider"></provider>
<activity android:theme="@android:01030055" android:name=".activity.DropboxBrowser">
<intent-filter >
<action android:name="android.intent.action.MAIN"></action>
<category android:name="android.intent.category.LAUNCHER"></category>
</intent-filter>
<intent-filter android:label="Dropbox File Browser">
<action android:name="com.dropbox.BROWSE"></action>
<action android:name="android.intent.action.VIEW"></action>
<action android:name="android.intent.action.EDIT"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<data android:mimeType="vnd.android.cursor.dir/vnd.dropbox.entry"></data>
<data android:mimeType="vnd.android.cursor.item/vnd.dropbox.entry"></data>
</intent-filter>
</activity>
如何理解主要活动的调用方式?我正在使用ApkAnalyser,我尝试了不同的类名和其他字符串,但是机器人测试无法启动应用程序,并写道我的项目中没有测试:/(apk在我的电脑中重新签名)我想了解,如何从apk文件中识别MainActivity?谢谢
我想使用Dropbox的JavaScript API(v2)从Dropbox读取文本文件的内容,我知道最接近的方法filesDownload().假设我们在根文件夹中有一个test.txt文件,内容为'abc'.我的JavaScript代码如下所示(我使用webpack)
var Dropbox = require('dropbox');
var dbx = new Dropbox({accessToken: '...'});
dbx.filesDownload({path: '/test.txt'})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
})
Run Code Online (Sandbox Code Playgroud)
实际返回一个对象,其中包含以下内容
Object {
client_modified: "2017-03-06T06:34:24Z"
content_hash: "f62f4917741f7ed26e883d8193ddf477cde87b99dfbd8d5d8f67eb400087e0b6"
...
}
Run Code Online (Sandbox Code Playgroud)
但是返回的对象中没有文件内容(例如"abc").相反,当我检查chrome浏览器控制台的网络选项卡时,我可以看到名为"download"的文件,其URL为" https://content.dropboxapi.com/2/files/download ",其内容为"abc" .
我的问题是,我怎样才能真正获得文件的内容?(一旦我可以获得内容,那么很容易在网页上显示它们)
我正在编写一个需要使用 Dropbox 网络钩子的程序。我还没有找到任何已经到位的 Go 实现,所以我决定写我的。不幸的是,它似乎不起作用。
我认为这里的问题是hmac,因为我很可能做错了什么,但我似乎无法理解这里的问题到底在哪里。任何的想法?
以下是我所拥有的:
package dboxwebhook
import (
"bytes"
"crypto/hmac"
"crypto/sha256"
"errors"
"io"
"io/ioutil"
"log"
)
type Signature struct {
AppSecret []byte
Signature []byte
}
func (w *Signature) Check(reqBody io.ReadCloser) error {
if bytes.Compare(w.Signature, nil) == 0 {
return errors.New("DropBox signature doesnt exist")
}
// building HMAC key (https://golang.org/pkg/crypto/hmac/)
mac := hmac.New(sha256.New, w.AppSecret)
requestBody, err := ioutil.ReadAll(reqBody)
if err != nil {
return err
}
mac.Write(requestBody)
expectedMac := mac.Sum(nil)
log.Println(w.AppSecret)
log.Println(expectedMac)
log.Println(w.Signature)
// compare if …Run Code Online (Sandbox Code Playgroud) dropbox-api ×6
dropbox ×4
python ×2
android ×1
api ×1
curl ×1
dropbox-php ×1
go ×1
hmac ×1
javascript ×1
php ×1
python-2.7 ×1
robotium ×1
sha256 ×1
testing ×1
webhooks ×1