问题
i'm trying to upload a file using the dropbox SDK for ios, i have setup correctly the framework, and link with the dropbox account, but now when i'm trying to upload the file i receive this error:
[WARNING] DropboxSDK: error making request to /1/files_put/sandbox/DBApp.sqlite - (403) Forbidden
2013-08-28 15:07:12.418 MyApp[3761:c07] File upload failed with error - Error Domain=dropbox.com Code=403 "The operation couldn’t be completed. (dropbox.com error 403.)" UserInfo=0x11e77ef0 {sourcePath=/Users/Piero/Library/Application Support/iPhone Simulator/6.1/Applications/553ACC67-D119-44A9-B7E0-7188773AD496/Documents/DBApp.sqlite, destinationPath=/sandbox/DBApp.sqlite, error=Forbidden}
this is the code i use:
NSString *filename = @"DBApp.sqlite";
NSString *destDir = @"/";
NSString *oldPath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent:@"DBApp.sqlite"];
[[self restClient] uploadFile:filename toPath:destDir withParentRev:nil fromPath:oldPath];
anyone can help me?
回答1:
i have found the problem, i have wrong to create the type account of the app in the dropbox page, i have choose Datastore Only, instead i have to choose file and Datastore, i have delete the account, and create a new one, and know with the code above works!
回答2:
Just for detail description.....
I was also getting the same error and followed a sample project form the ray wenderlich tutorial sites.
Steps what i have taken are as follow,
1)register(create) your app on drop box developer. 2)Choose DropBox API App
3)Choose sub type i.e What type of data does your app need to store on Dropbox: Files and Data-stores
4)Choose appropriate option Can your app be limited to its own folder?
5)What type of files does your app need access to?----> choose specific file type
for proper understanding have a look at attached snapshot......
I hope it may help to others......
回答3:
Ya I support Piero answer and another reason is that the access token is invalid so I suggest you to add the DBRestClient instance in your appdelegate OpenURL function so, your appdelegate class will have some thing like this AppDelegate .m
and in your ViewController add the DBRestClient instance from AppDelegate class in ViewDidLoad Method and your ViewController will looks something like this
This solves the issue and working fine
来源:https://stackoverflow.com/questions/18488937/upload-file-with-dropbox-sdk-for-ios-get-error-code-403