Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3501)

Unified Diff: chrome/browser/google_apis/drive_api_url_generator.cc

Issue 12225101: Implement GetInitiateUpload{New,Existing}FileUrl on Drive API v2. (Closed) Base URL: http://git.chromium.org/chromium/src.git@b148632_replace_url_to_resource_id_2
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/google_apis/drive_api_url_generator.cc
diff --git a/chrome/browser/google_apis/drive_api_url_generator.cc b/chrome/browser/google_apis/drive_api_url_generator.cc
index 7dc911d1feddb49912bc993fc8462722ff9881af..5387033e390c44667b6569034313a3e1c63c34ec 100644
--- a/chrome/browser/google_apis/drive_api_url_generator.cc
+++ b/chrome/browser/google_apis/drive_api_url_generator.cc
@@ -23,6 +23,13 @@ const char kDriveV2ChildrenUrlFormat[] = "/drive/v2/files/%s/children";
const char kDriveV2ChildrenUrlForRemovalFormat[] =
"/drive/v2/files/%s/children/%s";
const char kDriveV2FileTrashUrlFormat[] = "/drive/v2/files/%s/trash";
+const char kDriveV2InitiateUploadNewFileUrl[] = "/upload/drive/v2/files";
+const char kDriveV2InitiateUploadExistingFileUrlPrefix[] =
+ "/upload/drive/v2/files/";
+
+GURL AddResumableUploadParam(const GURL& url) {
+ return net::AppendOrReplaceQueryParameter(url, "uploadType", "resumable");
+}
} // namespace
@@ -96,4 +103,17 @@ GURL DriveApiUrlGenerator::GetChildrenUrlForRemoval(
net::EscapePath(child_id).c_str()));
}
+GURL DriveApiUrlGenerator::GetInitiateUploadNewFileUrl() const {
+ return AddResumableUploadParam(
+ base_url_.Resolve(kDriveV2InitiateUploadNewFileUrl));
+}
+
+GURL DriveApiUrlGenerator::GetInitiateUploadExistingFileUrl(
+ const std::string& resource_id) const {
+ const GURL& url = base_url_.Resolve(
+ kDriveV2InitiateUploadExistingFileUrlPrefix +
+ net::EscapePath(resource_id));
+ return AddResumableUploadParam(url);
+}
+
} // namespace google_apis
« no previous file with comments | « chrome/browser/google_apis/drive_api_url_generator.h ('k') | chrome/browser/google_apis/drive_api_url_generator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698