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 from Android application

Upload from Android application

sesha
Explorer | Level 4

I am uploading files from android phone to my Dropbox. The path/directory where I am writing is Apps/p19

my upload code does the following: But this never succeeds. 

mDBApi.putFile("Apps/p19/t.csv",inputStream, filename.length(), null, null);

 Is my path wrong or am i making any mistake in the putFile call ?

4 Replies 4

Greg-DB
Dropbox Staff

It looks like there are a few issues here:

  1. Based on "mDBApi.putFile", it looks like you're using an old and now retired Dropbox API (v1) and SDK. You should instead use Dropbox API v2. For accessing Dropbox API v2 from Android, we recommend using the official Dropbox API v2 Java SDK. There's an example Android app using it here. For uploading files, you can use the upload method.
  2. When specifying a non-root path, e.g., to indicate where the uploaded file should go, the path should start with a "/".
  3. If your app is registered for the "app folder" permission, you shouldn't include the "/Apps/<app folder name>" portion of the path. When making a call using an access token for an app with the app folder permission, the Dropbox API will automatically translate it to be relative to the app folder. So, you should just supply a path like "/t.csv".

sesha
Explorer | Level 4

Thanks. it worked with v2 api

aliazaz
New member | Level 2

How can I upload files to a specific folder in android

aliazaz
New member | Level 2

got the answer:

FileInputStream(file).use { item ->
val metadata = client.files().uploadBuilder("/$rootPATH/${file.absolutePath.substringAfterLast("/")}")
.uploadAndFinish(item)
}
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    aliazaz New member | Level 2
  • User avatar
    sesha Explorer | Level 4
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?