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: 

Getting File Metadata after doing upload - Android

Getting File Metadata after doing upload - Android

Robert S.138
Helpful | Level 7

To upload in Android I am using

sDbxClient.files().uploadBuilder(pathName)
.withMode(WriteMode.OVERWRITE)
.uploadAndFinish(inputStream);

which returns, what? The docs say it returns the server response as a "R".  How do I extract the file metadata from the server response to uploadAndFinish?  I want to get the server modified time from it.

 

I am looking for something equivalent to what I do in Objective-C, where is use the completion block of uploadData:mode:autorename:clientModified:mute:inputData:.

1 Accepted Solution

Accepted Solutions

Re: Getting File Metadata after doing upload - Android

Greg-DB
Dropboxer

R is the response, containing the metadata of the uploaded file. So, for example in this case you could do something like:

 

FileInputStream inputStream = new FileInputStream(localPath);
try {
    FileMetadata fileMetadata = client.files().uploadBuilder(remotePath)
            .withMode(WriteMode.OVERWRITE)
            .uploadAndFinish(inputStream);
    System.out.println(fileMetadata.getName());
    System.out.println(fileMetadata.getServerModified());
} finally {
    inputStream.close();
}

View solution in original post

3 Replies 3

Re: Getting File Metadata after doing upload - Android

Greg-DB
Dropboxer

R is the response, containing the metadata of the uploaded file. So, for example in this case you could do something like:

 

FileInputStream inputStream = new FileInputStream(localPath);
try {
    FileMetadata fileMetadata = client.files().uploadBuilder(remotePath)
            .withMode(WriteMode.OVERWRITE)
            .uploadAndFinish(inputStream);
    System.out.println(fileMetadata.getName());
    System.out.println(fileMetadata.getServerModified());
} finally {
    inputStream.close();
}

View solution in original post

Re: Getting File Metadata after doing upload - Android

Robert S.138
Helpful | Level 7

Thanks, it seems to work.  I thought it might be something like that.  But starting from the official docs for uploadAndFinish, all I could see was that it returned type R.  Where in the docs was I supposed to see that R was FileMetadata in this case?

Re: Getting File Metadata after doing upload - Android

Greg-DB
Dropboxer

UploadBuilder gives you an UploadUploader which is documented as DbxUploader<FileMetadata,UploadError,UploadErrorException>. 

 

That's definitely unclear/difficult to find if you're looking at uploadAndFinish itself though, so I'll ask the team to clarify that in the documentation. Thanks!

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
    Greg-DB Dropboxer
  • User avatar
    Robert S.138 Helpful | Level 7
What do Dropbox user levels mean?
Need more support?