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 File: update operation in mode field is not working

upload File: update operation in mode field is not working

Maithili P.
New member | Level 1

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 7

Steve M.
Dropbox Staff

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.
New member | Level 1

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"

 

Steve M.
Dropbox Staff

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.

田畑浩平
New member | Level 1

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
...

Steve M.
Dropbox Staff

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.

田畑浩平
New member | Level 1

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?

Steve M.
Dropbox Staff

Are you sure? I believe API v1 had the same behavior.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Steve M. Dropbox Staff
  • User avatar
    田畑浩平 New member | Level 1
What do Dropbox user levels mean?