cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Upload request for iOS mobile app

Upload request for iOS mobile app

sipius
Explorer | Level 3

Hello, this is my first time trying to upload a file to my companys dropbox account. 

The file is a 1 to 5 page pdf report that is generated.  I am able to generate, print and email report without a problem, but now would like to upload the report to dropbox also when it is emailed to keep as a record.

The report would go in different folders in dropbox that are already created based on project name.

I am getting the following erors on my upload request using objective c.......Please help.  Thank you!

NSData *fileData = [@"file data example" dataUsingEncoding:NSUTF8StringEncoding allowLossyConversation:NO];

****error#1: No visible @interface for 'NSString' declares the selector 'dataUsingEncoding:allowLossyConversation:’

 

DBFILESWriteMode *mode = [[DBFILESWriteMode allocinitWithOverwrite]; 

*****error#2:Initializer element is not a compile-time constant

 

    [[client.filesRoutes uploadData:@"/test/path/in/Dropbox/account/yourPDF.pdf”

******error#3: Expected identifier or ‘(‘    —first bracket and client are underlined in red

 

 

 

 

    

4 Replies 4

Greg-DB
Dropbox Staff

It looks like you're running in to a few different issues, some of which aren't about the Dropbox API/SDK in particular, but I'll offer what help I can. 

NSData *fileData = [@"file data example" dataUsingEncoding:NSUTF8StringEncoding allowLossyConversation:NO];

****error#1: No visible @interface for 'NSString' declares the selector 'dataUsingEncoding:allowLossyConversation:’

It looks like you have a typo in the parameter name. It should be "allowLossyConversion", not "allowLossyConversation". You can find an example here.

DBFILESWriteMode *mode = [[DBFILESWriteMode alloc] initWithOverwrite];

*****error#2:Initializer element is not a compile-time constant

Are you trying to run this outside of a function? Doing so will produce this error. Put this inside a function instead.

[[client.filesRoutes uploadData:@"/test/path/in/Dropbox/account/yourPDF.pdf”

******error#3: Expected identifier or ‘(‘ —first bracket and client are underlined in red

The code you shared here is incomplete. Make sure you implement it like in the example. Also, put it in a function, as above.

 

sipius
Explorer | Level 3

 

Thank you very much.  Now, the first two are solved, but #3 remains with this new message:

No visible @interface for 'DBFILESUserAuthRoutes' declares the selector 'uploadData:mode:autorename:clientModified:mute:propertyGroups:inputData:'

I'm not sure what the Dependencies are forDBFILESUserAuthRoutes?

     //         Code Below......................................................

 

Controller.m code:

      NSData *fileData = [@"file data example" dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO];    

    DBFILESWriteMode *mode = [[DBFILESWriteMode alloc] initWithOverwrite];

    [[[client.filesRoutes uploadData:@"/test/path/in/Dropbox/account/yourPDF.pdf"

                                mode:mode

                          autorename:@(YES)

                      clientModified:nil

                                mute:@(NO)

                      propertyGroups:nil

                           inputData:receivePdfData]

      setResponseBlock:^(DBFILESFILEMetadata *result, DBFILESUploadError *routeError, BDRequestError *networkError) {

          if (result) {

              NSLog(@"%@\n", result);

          } else {

              NSLog(@"%@\n%@\n", routeError, networkError);

          }

      }] setProgressBlock:^(int64_t bytesUploaded, int64_t totalBytesUploaded, int64_t totalBytesExpectedUploaded) {

          NSLog(@"\n%lld\n%lld\n%lld\n", bytesUploaded, totalBytesUploaded, totalBytesExpectedUploaded);

      }];

 

AppDelegate.m Code:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 

     [DBClientsManager setupWithAppKey:@"<APP_KEY_REDACTED>"];

       DBUserClient *client = [[DBUserClient alloc] initWithAccessToken:@"<ACCESS_TOKEN_REDACTED>"];

      return YES;

}

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {

    DBOAuthResult *authResult = [DBClientsManager handleRedirectURL:url];

    if (authResult != nil) {

        if ([authResult isSuccess]) {

            NSLog(@"Success! User is logged into dropbox.");

        } else if ([authResult isCancel]) {

            NSLog(@"Authorization flow was manually canceled by user!");

        } else if ([authResult isError]) {

            NSLog(@"Error: %@", authResult);

              }

    }

    return NO;

}

 

sipius
Explorer | Level 3

Thanks to your help I now have all the previous issues in the code resolved, but this message came up:

   :-1: linker command failed with exit code 1 (use -v to see invocation)

 

Greg-DB
Dropbox Staff

Please do not share your access token. I've redacted it from your previous post, but for the sake of security, you should disable that access token since you shared it publicly. You can do so by revoking access to the app entirely, if the access token is for your account, here.

Or, you can disable just that access token using via API, using any of the following:

Anyway, I'm glad to hear you resolved the other issues. Regarding the latest linker issue, please make sure you followed the installation instructions (for whichever of the three options you're using) exactly as documented. If you're still having trouble after double checking that, please try the potential fixes outlined in this issue.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    sipius Explorer | Level 3
What do Dropbox user levels mean?