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".
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
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.
After reading about then posting about the same error in the link provided by IanBailey, I changed:
var publicFolder = dropBoxStorage.GetFolder("/Public");
to
var publicFolder = dropBoxStorage.GetRoot();
The file then uploaded successfully.
EDIT: 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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With