Forum Discussion

bliss's avatar
bliss
Explorer | Level 3
8 years ago
Solved

upload image using apiv2 in iOS idk using objective c

How i can upload image usign objective c. I am using APIV2.

And i implemted it which display me an error.  Test 1 root folder here. I want to image uplaod in this folder

 

 

NSData *fileData = [@"water.jpg" dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO];
    
    [[[client.filesRoutes uploadData:@"/Test1/" inputData:fileData]
      setResponseBlock:^(DBFILESFileMetadata *result, DBFILESUploadError *routeError, DBRequestError *networkError) {
          if (result)
          {
              NSLog(@"%@\n", result);
          } else
          {
              NSLog(@"%@\n%@\n", routeError, networkError);
          }
      }] setProgressBlock:^(int64_t bytesUploaded, int64_t totalBytesUploaded, int64_t totalBytesExpectedToUploaded) {
          NSLog(@"\n%lld\n%lld\n%lld\n", bytesUploaded, totalBytesUploaded, totalBytesExpectedToUploaded);
      }];

 

ERROR----

 

DropboxBadInputError[{
    ErrorContent = "Error in call to API function \"files/upload\": path: invalid path: paths must not have a trailing \"/\"";
    RequestId = 9576332b860df94c12bcc13a28a6877a;
    StatusCode = 400;
    UserMessage = nil;
}];

 

  • This error message is expected in this case, as the file path you supply can't end with a "/", as yours does (@"/Test1/"). When uploading, you should supply the full path, including file name. You probably meant to supply something like @"/Test1/water.jpg" instead.
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff
    This error message is expected in this case, as the file path you supply can't end with a "/", as yours does (@"/Test1/"). When uploading, you should supply the full path, including file name. You probably meant to supply something like @"/Test1/water.jpg" instead.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,941 PostsLatest Activity: 8 hours ago
350 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!