cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done 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: 

problems uploading text files iOS

problems uploading text files iOS

Giordano58
Explorer | Level 3

Hi everbody,

 

in order to upgrade my app to Dropbox 2 I was trying upload and download festures.

While download seems to work I have some problems with uploading.

I am working with textual file with a small size, maximum 1 MB.

I followed the tutorial but after the upload is finished I only see on dropbox an empty small file of about 190 byte. It seems it is not able to upload the content of the file. Here is my code where db is the path of the file to upload. Thanks very much or the help.

 

NSData *fileData = [db dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO];
DBFILESWriteMode *mode = [[DBFILESWriteMode alloc] initWithOverwrite];
NSString *pathToSave = [[_startDirectory stringByAppendingString:@"/"] stringByAppendingString:file];
[[[userClient.filesRoutes uploadData:pathToSave mode:mode autorename:@(YES) clientModified:nil mute:@(NO) inputData:fileData] 
setResponseBlock:^(DBFILESFileMetadata *result, DBFILESUploadError *routeError, DBRequestError *networkError) {
if (result) {
NSLog(@"result:%@\n", result);}
                               else {
                                   NSLog(@"%@\n%@\n", routeError, networkError);
                               }
                           }] setProgressBlock:^(int64_t bytesUploaded, int64_t totalBytesUploaded, int64_t totalBytesExpectedToUploaded) {
                               NSLog(@"progress:\n%lld\n%lld\n%lld\n", bytesUploaded, totalBytesUploaded, totalBytesExpectedToUploaded);
                           }];

 

2 Replies 2

Re: problems uploading text files iOS

Greg-DB
Dropboxer
I can't see what `db` is in your code, but the rest of the code doesn't look obviously wrong. To troubleshoot this, can you first check whether or not `fileData` has the expected length when calling `uploadData`?

Re: problems uploading text files iOS

Giordano58
Explorer | Level 3

Hi Greg, thanks for the answer but I solved the problem making use of the following method:

 

[userClient.filesRoutes uploadUrl:pathToSave inputUrl:db]

 

Thanks again and regards,

Giordano

Poll
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?
Who's talking

Top contributors to this post

  • User avatar
    Giordano58 Explorer | Level 3
  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?