使用Sharpbox API上传到Dropbox [英] Uploading to Dropbox using Sharpbox API

查看:88
本文介绍了使用Sharpbox API上传到Dropbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Sharpbox API 将文件上传到我的保管箱帐户。但是,当我尝试将文件上传到公共文件夹时,出现一条错误消息:无法从服务器检索子元素。

I am attempting to use the Sharpbox API to upload a file to my dropbox account. However, when I attempt to upload a file to the "Public" folder, I get an error stating: "Couldn't retrieve child elements from the server".

我已按照文档第10-11页上的步骤进行操作pdf ,这是我当前正在使用的代码(作为测试,我试图上传token.txt文件):

I have followed the steps on page 10-11 of the documentation pdf and here is the code I am currently using (as a test I am trying to upload the token.txt file):

Public Sub StoreOnDropbox()

    Dim oDBox As New CloudStorage
    Dim oDBoxConfig As AppLimit.CloudComputing.SharpBox.ICloudStorageConfiguration = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox)
    Dim oAccessToken As ICloudStorageAccessToken = Nothing

    Using fs As IO.FileStream = File.Open("C:\Users\davidd5\Desktop\token.txt", FileMode.Open, FileAccess.Read, FileShare.None)
        oAccessToken = oDBox.DeserializeSecurityToken(fs)
    End Using
    Dim oStorageToken = oDBox.Open(oDBoxConfig, oAccessToken)
    Dim srcFile = Environment.ExpandEnvironmentVariables("C:\Users\davidd5\Desktop\token.txt")
    Dim publicFolder = oDBox.GetFolder("/Public")
    oDBox.UploadFile(srcFile, publicFolder)

    oDBox.Close()

End Sub

该错误发生在GetFolder函数上。我已经标记了vb.net和C#,因为该文档位于C#中,并且已将其翻译为vb.net。

The error occurs on the GetFolder function. I have tagged both vb.net and C# as the documentation is in C# and I've translated it to vb.net.

在阅读并随后在IanBailey提供的链接中发布了大约相同的错误之后,我进行了更改:

After reading about then posting about the same error in the link provided by IanBailey, I changed:

var publicFolder = dropBoxStorage.GetFolder("/Public");

  var publicFolder = dropBoxStorage.GetRoot();

文件成功上传。

编辑:但是,我刚刚意识到您不能在apps文件夹(GetRoot指向)中共享文件,因此问题仍然存在。

However, I just realised that you cannot share files within the apps folder (that GetRoot points to), so therefore the problem is still occurring for me.

编辑2:我认为问题是由于在保管箱上创建应用程序时的权限所致。首次创建应用程序时,可以选择授予对 Apps文件夹或整个用户的保管箱的访问权限。我遇到了错误,然后创建了一个新应用,该应用请求访问整个用户的保管箱,然后能够访问公用文件夹。

EDIT 2: I think the problem is due to permissions when creating your app on dropbox. When you first create the app, there is the option to grant access to either the "Apps" folder, or the entire users' dropbox. I was getting the error then I created a new app that requested access to the entire users' dropbox and was then able to get at the public folder.

推荐答案

问题是由于在保管箱上创建应用程序时的权限所致。首次创建应用程序时,可以选择授予对 Apps文件夹或整个用户的保管箱的访问权限。在创建新应用程序之前,我一直遇到错误,该应用程序要求访问整个用户的保管箱,然后能够访问公用文件夹。

The problem is due to permissions when creating your app on dropbox. When you first create the app, there is the option to grant access to either the "Apps" folder, or the entire users' dropbox. I was getting the error until I created a new app that requested access to the entire users' dropbox and was then able to get at the public folder.

这篇关于使用Sharpbox API上传到Dropbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆