You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

sipius's avatar
sipius
Explorer | Level 3
6 years ago

Upload request for iOS mobile app

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

 

 

 

 

    

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox 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's avatar
      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's avatar
        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)