Skip to content

Commit

Permalink
Allow uploading files via direct upload, which can be faster
Browse files Browse the repository at this point in the history
  • Loading branch information
jffry committed Mar 1, 2016
1 parent 242ae1c commit ee4931b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/google_apps_clj/google_drive.clj
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
:file-id - specifies the file for file-specific models and actions"
[google-ctx query]
(let [drive (build-drive-service google-ctx)
{:keys [model action fields]} query
{:keys [model action fields direct-upload]} query

This comment has been minimized.

Copy link
@dball

dball Mar 1, 2016

Contributor

👍 tho my general inclination is for boolean fields to have a trailing ? symbol

;; TODO more rigorous support for nesting, e.g. permissions(role,type)
fields (when (seq fields) (string/join "," (map name fields)))
items? (= :list action)
Expand Down Expand Up @@ -295,6 +295,12 @@
(doto (.insert (.files drive) file stream)
(.setConvert convert))
(.insert (.files drive) file))]
;Allow direct upload, which is more efficient for tiny files
;https://developers.google.com/api-client-library/java/google-api-java-client/media-upload#direct
(when direct-upload
(when-let [uploader (.getMediaHttpUploader request)]

This comment has been minimized.

Copy link
@dball

dball Mar 1, 2016

Contributor

Why not just let? Wouldn't we want to error if the user requested direct-upload and the request object was unable to satisfy it for whatever reason?

(.setDirectUploadEnabled uploader true)))
;Allow requesting specific fields only in response, which can be more efficient
(cond-doto ^DriveRequest request
fields (.setFields fields))))
:permissions
Expand Down

0 comments on commit ee4931b

Please sign in to comment.