0

我希望用户上传到我们的服务器,然后让我们的服务器使用 API 将文件上传到 Box 中的特定文件夹。我怎样才能做到这一点?我应该使用什么凭据?

curl https://app.box.com/api/oauth2/token \
-d 'grant_type=client_credentials&client_id=CLIENT_ID&client_secret=SECRET'

返回

{"access_token":"TOKEN","expires_in":3793,"restricted_to":[],"token_type":"bearer"}

curl https://upload.box.com/api/2.0/files/content   \
-H "Authorization: Bearer TOKEN" -X POST  -F \ 
file=@package.json -F folder_id=3306197480

返回

{"type":"error","status":404,"code":"not_found","context_info":{"errors":[{"reason":"invalid_parameter","name":"parent", "message":"无效值 'd_3306197480'。未找到值为 'd_3306197480' 的'父'"}]},"help_url":"http://developers.box.com/docs/#errors","message" :"未找到","re​​quest_id":"1157604954550c7c754b9c9"}

4

1 回答 1

4

听起来 API 正在返回 404,因为与访问令牌关联的用户无权查看您要上传到的文件夹。您的服务器将需要以在该文件夹上协作的用户身份进行身份验证,而不是以上传文件的用户身份进行身份验证。

于 2015-03-26T07:43:26.900 回答