Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91207 > unrolled thread
| Started by | zljubisicmob@gmail.com |
|---|---|
| First post | 2015-05-25 12:10 -0700 |
| Last post | 2015-05-25 23:26 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.python
Why dropbox.client.DropboxClient.put_file needs file_obj as a parameter? zljubisicmob@gmail.com - 2015-05-25 12:10 -0700
Re: Why dropbox.client.DropboxClient.put_file needs file_obj as a parameter? Skip Montanaro <skip.montanaro@gmail.com> - 2015-05-25 15:02 -0500
Re: Why dropbox.client.DropboxClient.put_file needs file_obj as a parameter? "Zoran Ljubisic (mob)" <zljubisicmob@gmail.com> - 2015-05-25 23:26 +0200
| From | zljubisicmob@gmail.com |
|---|---|
| Date | 2015-05-25 12:10 -0700 |
| Subject | Why dropbox.client.DropboxClient.put_file needs file_obj as a parameter? |
| Message-ID | <93ce55bf-3b0d-42ce-b514-2326f45ca2bb@googlegroups.com> |
Hi
as I can see dropbox.client.DropboxClient.put_file has four parameters:
"
full_path
The full path to upload the file to, including the file name. If the destination folder does not yet exist, it will be created.
file_obj
A file-like object to upload. If you would like, you can pass a string as file_obj.
overwrite
Whether to overwrite an existing file at the given path. (Default False.) If overwrite is False and a file already exists there, Dropbox will rename the upload to make sure it doesn't overwrite anything. You need to check the metadata returned for the new name. This field should only be True if your intent is to potentially clobber changes to a file that you don't know about.
parent_rev
Optional rev field from the 'parent' of this upload. If your intent is to update the file at the given path, you should pass the parent_rev parameter set to the rev value from the most recent metadata you have of the existing file at that path. If the server has a more recent version of the file at the specified path, it will automatically rename your uploaded file, spinning off a conflict. Using this parameter effectively causes the overwrite parameter to be ignored. The file will always be overwritten if you send the most recent parent_rev, and it will never be overwritten if you send a less recent one.
"
What is the purpose of file_obj parameter?
f = open('working-draft.txt', 'rb')
response = client.put_file('/magnum-opus.txt', f)
print "uploaded:", response
In the example above there are two files working-draft.txt and magnum-opus.txt.
If I want to upload magnum-opus.txt, why do I need working-draft.txt?
Furthermore, if I want to update the file, how to find out parent_rev parameter?
As you can see I am a little bit confused. :)
Regards.
[toc] | [next] | [standalone]
| From | Skip Montanaro <skip.montanaro@gmail.com> |
|---|---|
| Date | 2015-05-25 15:02 -0500 |
| Message-ID | <mailman.41.1432584177.5151.python-list@python.org> |
| In reply to | #91207 |
[Multipart message — attachments visible in raw view] — view raw
Looks like the file_obj is what you are reading locally, and magnum_opus.txt is the destination name on Dropbox. Skip
[toc] | [prev] | [next] | [standalone]
| From | "Zoran Ljubisic (mob)" <zljubisicmob@gmail.com> |
|---|---|
| Date | 2015-05-25 23:26 +0200 |
| Message-ID | <mailman.43.1432589184.5151.python-list@python.org> |
| In reply to | #91207 |
[Multipart message — attachments visible in raw view] — view raw
Looks like you are right. Thanks for clarification. Regards. On May 25, 2015 10:02 PM, "Skip Montanaro" <skip.montanaro@gmail.com> wrote: > Looks like the file_obj is what you are reading locally, and > magnum_opus.txt is the destination name on Dropbox. > > Skip >
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web