diff options
author | hirono <hirono@chromium.org> | 2014-12-08 20:07:39 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-09 04:07:56 +0000 |
commit | a06f78ce0b99f2bd2251b3ee0260766c2a1192e8 (patch) | |
tree | fe422748ae665e81f9b46b4bd26ed2090ebca590 /google_apis/drive/drive_api_url_generator.cc | |
parent | f3c2e92f9a35997dcee435f03d77e5962bb82fb0 (diff) | |
download | chromium_src-a06f78ce0b99f2bd2251b3ee0260766c2a1192e8.zip chromium_src-a06f78ce0b99f2bd2251b3ee0260766c2a1192e8.tar.gz chromium_src-a06f78ce0b99f2bd2251b3ee0260766c2a1192e8.tar.bz2 |
DriveAPI: Add mehtod to create URL for multipart uploading.
The CL adds the following two methods to DriveApiUrlGenerator.
* GetMultipartUploadNewFileUrl
* GetMultipartUploadExistingFileUrl
BUG=269922
TEST=DriveApiUrlGeneratorTest
Review URL: https://codereview.chromium.org/772323004
Cr-Commit-Position: refs/heads/master@{#307413}
Diffstat (limited to 'google_apis/drive/drive_api_url_generator.cc')
-rw-r--r-- | google_apis/drive/drive_api_url_generator.cc | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/google_apis/drive/drive_api_url_generator.cc b/google_apis/drive/drive_api_url_generator.cc index b8374e27..310dfdb 100644 --- a/google_apis/drive/drive_api_url_generator.cc +++ b/google_apis/drive/drive_api_url_generator.cc @@ -27,8 +27,8 @@ const char kDriveV2ChildrenUrlForRemovalFormat[] = const char kDriveV2FileCopyUrlFormat[] = "/drive/v2/files/%s/copy"; const char kDriveV2FileDeleteUrlFormat[] = "/drive/v2/files/%s"; const char kDriveV2FileTrashUrlFormat[] = "/drive/v2/files/%s/trash"; -const char kDriveV2InitiateUploadNewFileUrl[] = "/upload/drive/v2/files"; -const char kDriveV2InitiateUploadExistingFileUrlPrefix[] = +const char kDriveV2UploadNewFileUrl[] = "/upload/drive/v2/files"; +const char kDriveV2UploadExistingFileUrlPrefix[] = "/upload/drive/v2/files/"; const char kDriveV2PermissionsUrlFormat[] = "/drive/v2/files/%s/permissions"; @@ -43,6 +43,10 @@ GURL AddResumableUploadParam(const GURL& url) { return net::AppendOrReplaceQueryParameter(url, "uploadType", "resumable"); } +GURL AddMultipartUploadParam(const GURL& url) { + return net::AppendOrReplaceQueryParameter(url, "uploadType", "multipart"); +} + } // namespace DriveApiUrlGenerator::DriveApiUrlGenerator(const GURL& base_url, @@ -188,7 +192,7 @@ GURL DriveApiUrlGenerator::GetChildrenDeleteUrl( GURL DriveApiUrlGenerator::GetInitiateUploadNewFileUrl( bool set_modified_date) const { GURL url = AddResumableUploadParam( - base_url_.Resolve(kDriveV2InitiateUploadNewFileUrl)); + base_url_.Resolve(kDriveV2UploadNewFileUrl)); // setModifiedDate is "false" by default. if (set_modified_date) @@ -201,7 +205,7 @@ GURL DriveApiUrlGenerator::GetInitiateUploadExistingFileUrl( const std::string& resource_id, bool set_modified_date) const { GURL url = base_url_.Resolve( - kDriveV2InitiateUploadExistingFileUrlPrefix + + kDriveV2UploadExistingFileUrlPrefix + net::EscapePath(resource_id)); url = AddResumableUploadParam(url); @@ -212,6 +216,33 @@ GURL DriveApiUrlGenerator::GetInitiateUploadExistingFileUrl( return url; } +GURL DriveApiUrlGenerator::GetMultipartUploadNewFileUrl( + bool set_modified_date) const { + GURL url = AddMultipartUploadParam( + base_url_.Resolve(kDriveV2UploadNewFileUrl)); + + // setModifiedDate is "false" by default. + if (set_modified_date) + url = net::AppendOrReplaceQueryParameter(url, "setModifiedDate", "true"); + + return url; +} + +GURL DriveApiUrlGenerator::GetMultipartUploadExistingFileUrl( + const std::string& resource_id, + bool set_modified_date) const { + GURL url = base_url_.Resolve( + kDriveV2UploadExistingFileUrlPrefix + + net::EscapePath(resource_id)); + url = AddMultipartUploadParam(url); + + // setModifiedDate is "false" by default. + if (set_modified_date) + url = net::AppendOrReplaceQueryParameter(url, "setModifiedDate", "true"); + + return url; +} + GURL DriveApiUrlGenerator::GenerateDownloadFileUrl( const std::string& resource_id) const { return base_download_url_.Resolve(net::EscapePath(resource_id)); |