cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Get summer ready with Dropbox basic - travel documents, plans, progress reminders and more, right over 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: 

iOS Objective C. up/download URL.

iOS Objective C. up/download URL.

AppleGG
Helpful | Level 6

I can't seem to get the right response block for these. A little Help?

 

Also one parameter is labeled as a URL but takes a string, which I assume is a path.

 

Your web page examples on file transfers are in sore need of being updated.

5 Replies 5

Re: iOS Objective C. up/download URL.

Greg-DB
Dropboxer

It sounds like you're referring to uploadUrl and downloadUrl. The documentation there has more information, but the first parameter to each is the remote path in Dropbox (that is, the path where you want to upload to or download from, respectively.) The URL parameter is likewise the file URL to upload from or download to, respectively.

 

Here are some examples of what those would look like:

 

[[client.filesRoutes uploadUrl:@"/test.txt" inputUrl:[NSURL fileURLWithPath:@"/local/path/to/test.txt"]]
 setResponseBlock:^(DBFILESFileMetadata *metadata, DBFILESUploadError *uploadError, DBRequestError *error) {
    if (metadata) {
        NSLog(@"The upload completed successfully.");
        NSLog(@"File metadata:");
        NSLog(@"%@", metadata);
    } else if (uploadError) {
        NSLog(@"Something went wrong with the upload:");
        NSLog(@"%@", uploadError);
    } else if (error) {
        NSLog(@"Something went wrong with the API call:");
        NSLog(@"%@", error);
    }
}];
[[client.filesRoutes downloadUrl:@"/test.txt" overwrite:true destination:[NSURL fileURLWithPath:@"/local/path/to/test.txt"]]
 setResponseBlock:^(DBFILESFileMetadata *metadata, DBFILESDownloadError *downloadError, DBRequestError *error, NSURL *destination) {
         if (metadata) {
             NSLog(@"The download call completed successfully.");
             NSLog(@"File metadata:");
             NSLog(@"%@", metadata);
         } else if (downloadError) {
             NSLog(@"Something went wrong with the download:");
             NSLog(@"%@", downloadError);
         } else if (error) {
             NSLog(@"Something went wrong with the API call:");
             NSLog(@"%@", error);
         }
 }];

 

If this isn't working for you, can you share the code that isn't working for you and the error you're getting?

Re: iOS Objective C. up/download URL.

tslanina
New member | Level 2

Hey,

Your example contains:

inputUrl:[NSURL fileURLWithPath:@"/local/path/to/test.txt"

But when you check DBFILESUserAuthRoutes, there's :

- (DBUploadTask *)uploadUrl:(NSString *)path inputUrl:(NSString *)inputUrl

So, the inputUrl argument is an NSString, not NSURL type.

Moreover, uploadUrl calls requestUpload, where the inputUrl (named as input) is converted to NSURL:

 

- (DBUploadTaskImpl *)requestUpload:(DBRoute *)route arg:(id<DBSerializable>)arg inputUrl:(NSString *)input {
  NSURL *inputUrl = [NSURL fileURLWithPath:input];

 

So, reasuming. Direct file path ( NSString*) should be passed to uploadUrl,  not the URL.

The "inputUrl" name is also misleading (probably leftover from previous version??),  should be inputPath, so

 

inputUrl:(NSURL *)inputUrl

 

or

 

inputPath:(NSString *)inputUrl  

 

Would be much better.

The same problem is with other args with "Url" in name abd NSString* type.

Re: iOS Objective C. up/download URL.

Greg-DB
Dropboxer

@tslanina That's correct, these NSURL parameters were changed to NSString in v3.0.11 after I wrote the examples above.

 

I'll send this along to the team as a request to update the method/parameter names to clarify.

Re: iOS Objective C. up/download URL.

Bob S.15
Helpful | Level 6

I'm getting an "unrecognized selector sent to instance" for uploadURL. Trying to update to newest SDK from the old one that supported iOS 8.  Those links you posted are broken.  Is uploadURL gone?  What's its replacement???

Re: iOS Objective C. up/download URL.

Greg-DB
Dropboxer
Poll
Which Dropbox Plan do you have?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    Bob S.15 Helpful | Level 6
  • User avatar
    tslanina New member | Level 2
What do Dropbox user levels mean?
Need more support?