Forum Discussion

Maithili P.'s avatar
Maithili P.
New member | Level 1
10 years ago

upload File: update operation in mode field is not working

Hi,

I am working on developing an integration, would like to know the behaviour of upload file activity for mode field. Below are the steps

1. I have defined valid Path and upload a file

2. file is uploaded and ID and rev is generated in response

3. now i have updated the same file (in local drive) which i have uploaded in above steps

4. again try to upload that file (updated content) by using mode value as

"mode": {".tag":"update","update":"<rev no>"},

5. In response, again same rev is displayed. It seems that file is not uploaded with updated content

Is there any API issue?. or Please suggest if i am executing wrong steps?

Thanks,

Maithili

 

 

 

 

7 Replies

  • Are you actually uploading new content, or is the new file identical to the old file? (If the content is identical, Dropbox basically ignores the update.)

    If that's not it, please share some code that can reproduce the issue.

  • Maithili P.'s avatar
    Maithili P.
    New member | Level 1
    10 years ago

    Thanks Steve

    Actually I am trying to update the existing file

    For ex:

    1. I have uploaded file "file1.xlsx" with data as "ABCD"

    2. Now in my local file I have updated the file content as "ABCD-1234" and again try to upload it in Dropbox file "file1.xlsx".

    {"path": "/folder1/file1.xlsx","mode": {".tag":"update", "update":"<rev>"},"autorename": false, "mute": false }

    3. Upload is done but the "file1.xlsx" is not updated. It is showing old content i.e "ABCD"

     

  • If the upload succeeds, that means the file was indeed updated (or the contents weren't changed). Some ideas of things to check:

    1. Did you really send updated content via the API? (E.g. maybe you're editing the wrong file, not the one you're actually uploading.)
    2. Are you looking at the right file when you're trying to verify that the upload succeeded? (E.g. maybe the file is being updated but you're checking the wrong file.)

    As a sanity check, you might try logging the file size and timestamp in your code right before upload. That way you can double check that you're uploading what you expect.

  • 田畑浩平's avatar
    田畑浩平
    New member | Level 1
    10 years ago

    Hi, Steve.

    I also encountered exactly same problem.

    I'm developing iOS app and switching from dropbox-ios-sdk to SwiftyDropbox(v1 -> v2).

    And almost features works fine, but I can't resolve this problem with upload feature.

    I check upload feature with SwiftyDropbox and curl command.


    And when I try to upload some files with curl command, it won't work as I expected.
    So I suspect upload api.

    ```
    curl -X POST https://content.dropboxapi.com/2/files/upload \
        --header "Authorization: Bearer ***********************************************************************************************” \
        --header "Dropbox-API-Arg: {\"path\": \”/sample.jpg\",\"mode\": \”add\”,\”autorename\": true,\"mute\": false}" \
        --header "Content-Type: application/octet-stream" \
        --data-binary @sample.jpg
    ```

    {"name": "sample.jpg", "path_lower": "/sample.jpg", "path_display": "/sample.jpg", "id": "id:********************", "client_modified": "2016-08-27T13:55:11Z", "server_modified": "2016-08-27T13:55:11Z", "rev": "135cc0934ed6f", "size": 527359}

    I expect that file name which is included within response changes like below when I call api several times, but api returns above result when I call api several times.
    Is my expectation is wrong?

    sample.jpg
    sample1.jpg
    sample2.jpg
    sample3.jpg
    ...

  • As I said earlier in this thread: "Are you actually uploading new content, or is the new file identical to the old file? (If the content is identical, Dropbox basically ignores the update.)"

    My guess is that you're not changing the contents of sample.jpg in between upload attempts. If the content is unchanged, there's no conflict, and thus there's no rename.

  • 田畑浩平's avatar
    田畑浩平
    New member | Level 1
    10 years ago

    Thanks Steve.

    I overlooked what you said.
    I tried to upload new file identical to the old file.

    With dropbox-ios-sdk(v1 API?), it rename files
    when I tried to upload new file identical to the old file.


    Is it specification change from v1 API to v2 API?

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!