@@ -848,31 +848,41 @@ def files_alpha_upload(self,
848
848
client_modified = None ,
849
849
mute = False ,
850
850
property_groups = None ,
851
- strict_conflict = False ):
851
+ strict_conflict = False ,
852
+ content_hash = None ):
852
853
"""
853
854
Create a new file with the contents provided in the request. Note that
854
- this endpoint is part of the properties API alpha and is slightly
855
- different from :meth:`files_upload`. Do not use this to upload a file
856
- larger than 150 MB. Instead, create an upload session with
857
- :meth:`files_upload_session_start`.
855
+ the behavior of this alpha endpoint is unstable and subject to change.
856
+ Do not use this to upload a file larger than 150 MB. Instead, create an
857
+ upload session with :meth:`files_upload_session_start`.
858
858
859
859
Route attributes:
860
860
scope: files.content.write
861
861
862
862
:param bytes f: Contents to upload.
863
+ :param Nullable[str] content_hash: A hash of the file content uploaded
864
+ in this call. If provided and the uploaded content does not match
865
+ this hash, an error will be returned. For more information see our
866
+ `Content hash
867
+ <https://www.dropbox.com/developers/reference/content-hash>`_ page.
863
868
:rtype: :class:`dropbox.files.FileMetadata`
869
+ :raises: :class:`.exceptions.ApiError`
870
+
871
+ If this raises, ApiError will contain:
872
+ :class:`dropbox.files.UploadError`
864
873
"""
865
874
warnings .warn (
866
- 'alpha/upload is deprecated. Use alpha/ upload.' ,
875
+ 'alpha/upload is deprecated. Use upload.' ,
867
876
DeprecationWarning ,
868
877
)
869
- arg = files .CommitInfoWithProperties (path ,
870
- mode ,
871
- autorename ,
872
- client_modified ,
873
- mute ,
874
- property_groups ,
875
- strict_conflict )
878
+ arg = files .UploadArg (path ,
879
+ mode ,
880
+ autorename ,
881
+ client_modified ,
882
+ mute ,
883
+ property_groups ,
884
+ strict_conflict ,
885
+ content_hash )
876
886
r = self .request (
877
887
files .alpha_upload ,
878
888
'files' ,
@@ -3157,7 +3167,8 @@ def files_upload(self,
3157
3167
client_modified = None ,
3158
3168
mute = False ,
3159
3169
property_groups = None ,
3160
- strict_conflict = False ):
3170
+ strict_conflict = False ,
3171
+ content_hash = None ):
3161
3172
"""
3162
3173
Create a new file with the contents provided in the request. Do not use
3163
3174
this to upload a file larger than 150 MB. Instead, create an upload
@@ -3171,43 +3182,25 @@ def files_upload(self,
3171
3182
scope: files.content.write
3172
3183
3173
3184
:param bytes f: Contents to upload.
3174
- :param str path: Path in the user's Dropbox to save the file.
3175
- :param mode: Selects what to do if the file already exists.
3176
- :type mode: :class:`dropbox.files.WriteMode`
3177
- :param bool autorename: If there's a conflict, as determined by
3178
- ``mode``, have the Dropbox server try to autorename the file to
3179
- avoid conflict.
3180
- :param Nullable[datetime] client_modified: The value to store as the
3181
- ``client_modified`` timestamp. Dropbox automatically records the
3182
- time at which the file was written to the Dropbox servers. It can
3183
- also record an additional timestamp, provided by Dropbox desktop
3184
- clients, mobile clients, and API apps of when the file was actually
3185
- created or modified.
3186
- :param bool mute: Normally, users are made aware of any file
3187
- modifications in their Dropbox account via notifications in the
3188
- client software. If ``True``, this tells the clients that this
3189
- modification shouldn't result in a user notification.
3190
- :param Nullable[List[:class:`dropbox.files.PropertyGroup`]]
3191
- property_groups: List of custom properties to add to file.
3192
- :param bool strict_conflict: Be more strict about how each
3193
- :class:`dropbox.files.WriteMode` detects conflict. For example,
3194
- always return a conflict error when ``mode`` = ``WriteMode.update``
3195
- and the given "rev" doesn't match the existing file's "rev", even if
3196
- the existing file has been deleted. This also forces a conflict even
3197
- when the target path refers to a file with identical contents.
3185
+ :param Nullable[str] content_hash: A hash of the file content uploaded
3186
+ in this call. If provided and the uploaded content does not match
3187
+ this hash, an error will be returned. For more information see our
3188
+ `Content hash
3189
+ <https://www.dropbox.com/developers/reference/content-hash>`_ page.
3198
3190
:rtype: :class:`dropbox.files.FileMetadata`
3199
3191
:raises: :class:`.exceptions.ApiError`
3200
3192
3201
3193
If this raises, ApiError will contain:
3202
3194
:class:`dropbox.files.UploadError`
3203
3195
"""
3204
- arg = files .CommitInfo (path ,
3205
- mode ,
3206
- autorename ,
3207
- client_modified ,
3208
- mute ,
3209
- property_groups ,
3210
- strict_conflict )
3196
+ arg = files .UploadArg (path ,
3197
+ mode ,
3198
+ autorename ,
3199
+ client_modified ,
3200
+ mute ,
3201
+ property_groups ,
3202
+ strict_conflict ,
3203
+ content_hash )
3211
3204
r = self .request (
3212
3205
files .upload ,
3213
3206
'files' ,
@@ -3219,7 +3212,8 @@ def files_upload(self,
3219
3212
def files_upload_session_append_v2 (self ,
3220
3213
f ,
3221
3214
cursor ,
3222
- close = False ):
3215
+ close = False ,
3216
+ content_hash = None ):
3223
3217
"""
3224
3218
Append more data to an upload session. When the parameter close is set,
3225
3219
this call will close the session. A single request should not upload
@@ -3240,14 +3234,20 @@ def files_upload_session_append_v2(self,
3240
3234
point you won't be able to call
3241
3235
:meth:`files_upload_session_append_v2` anymore with the current
3242
3236
session.
3237
+ :param Nullable[str] content_hash: A hash of the file content uploaded
3238
+ in this call. If provided and the uploaded content does not match
3239
+ this hash, an error will be returned. For more information see our
3240
+ `Content hash
3241
+ <https://www.dropbox.com/developers/reference/content-hash>`_ page.
3243
3242
:rtype: None
3244
3243
:raises: :class:`.exceptions.ApiError`
3245
3244
3246
3245
If this raises, ApiError will contain:
3247
- :class:`dropbox.files.UploadSessionLookupError `
3246
+ :class:`dropbox.files.UploadSessionAppendError `
3248
3247
"""
3249
3248
arg = files .UploadSessionAppendArg (cursor ,
3250
- close )
3249
+ close ,
3250
+ content_hash )
3251
3251
r = self .request (
3252
3252
files .upload_session_append_v2 ,
3253
3253
'files' ,
@@ -3282,7 +3282,7 @@ def files_upload_session_append(self,
3282
3282
:raises: :class:`.exceptions.ApiError`
3283
3283
3284
3284
If this raises, ApiError will contain:
3285
- :class:`dropbox.files.UploadSessionLookupError `
3285
+ :class:`dropbox.files.UploadSessionAppendError `
3286
3286
"""
3287
3287
warnings .warn (
3288
3288
'upload_session/append is deprecated. Use upload_session/append.' ,
@@ -3301,7 +3301,8 @@ def files_upload_session_append(self,
3301
3301
def files_upload_session_finish (self ,
3302
3302
f ,
3303
3303
cursor ,
3304
- commit ):
3304
+ commit ,
3305
+ content_hash = None ):
3305
3306
"""
3306
3307
Finish an upload session and save the uploaded data to the given file
3307
3308
path. A single request should not upload more than 150 MB. The maximum
@@ -3321,14 +3322,20 @@ def files_upload_session_finish(self,
3321
3322
:param commit: Contains the path and other optional modifiers for the
3322
3323
commit.
3323
3324
:type commit: :class:`dropbox.files.CommitInfo`
3325
+ :param Nullable[str] content_hash: A hash of the file content uploaded
3326
+ in this call. If provided and the uploaded content does not match
3327
+ this hash, an error will be returned. For more information see our
3328
+ `Content hash
3329
+ <https://www.dropbox.com/developers/reference/content-hash>`_ page.
3324
3330
:rtype: :class:`dropbox.files.FileMetadata`
3325
3331
:raises: :class:`.exceptions.ApiError`
3326
3332
3327
3333
If this raises, ApiError will contain:
3328
3334
:class:`dropbox.files.UploadSessionFinishError`
3329
3335
"""
3330
3336
arg = files .UploadSessionFinishArg (cursor ,
3331
- commit )
3337
+ commit ,
3338
+ content_hash )
3332
3339
r = self .request (
3333
3340
files .upload_session_finish ,
3334
3341
'files' ,
@@ -3447,7 +3454,8 @@ def files_upload_session_finish_batch_check(self,
3447
3454
def files_upload_session_start (self ,
3448
3455
f ,
3449
3456
close = False ,
3450
- session_type = None ):
3457
+ session_type = None ,
3458
+ content_hash = None ):
3451
3459
"""
3452
3460
Upload sessions allow you to upload a single file in one or more
3453
3461
requests, for example where the size of the file is greater than 150 MB.
@@ -3495,14 +3503,20 @@ def files_upload_session_start(self,
3495
3503
:param Nullable[:class:`dropbox.files.UploadSessionType`] session_type:
3496
3504
Type of upload session you want to start. If not specified, default
3497
3505
is ``UploadSessionType.sequential``.
3506
+ :param Nullable[str] content_hash: A hash of the file content uploaded
3507
+ in this call. If provided and the uploaded content does not match
3508
+ this hash, an error will be returned. For more information see our
3509
+ `Content hash
3510
+ <https://www.dropbox.com/developers/reference/content-hash>`_ page.
3498
3511
:rtype: :class:`dropbox.files.UploadSessionStartResult`
3499
3512
:raises: :class:`.exceptions.ApiError`
3500
3513
3501
3514
If this raises, ApiError will contain:
3502
3515
:class:`dropbox.files.UploadSessionStartError`
3503
3516
"""
3504
3517
arg = files .UploadSessionStartArg (close ,
3505
- session_type )
3518
+ session_type ,
3519
+ content_hash )
3506
3520
r = self .request (
3507
3521
files .upload_session_start ,
3508
3522
'files' ,
0 commit comments