Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

sesha's avatar
sesha
Explorer | Level 4
7 years ago

Upload from Android application

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

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    7 years ago

    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's avatar
    sesha
    Explorer | Level 4
    7 years ago

    Thanks. it worked with v2 api

  • aliazaz's avatar
    aliazaz
    New member | Level 2
    6 years ago

    How can I upload files to a specific folder in android

  • aliazaz's avatar
    aliazaz
    New member | Level 2
    6 years ago

    got the answer:

    FileInputStream(file).use { item ->
    val metadata = client.files().uploadBuilder("/$rootPATH/${file.absolutePath.substringAfterLast("/")}")
    .uploadAndFinish(item)
    }

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!