Last active
December 19, 2015 22:09
-
-
Save ThomasHintz/6025759 to your computer and use it in GitHub Desktop.
Idea for amazon-s3 api improvement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (put-options #!key canned-acl metadata content-type expires storage-class) | |
(when (and canned-acl | |
(not (member canned-acl '(private full-control public read authenticated-read)))) | |
(error "invalid canned-acl specified")) | |
(filter (cut cdr <>) | |
`((canned-acl . ,canned-acl) (metadata . ,metadata) (content-type . ,content-type) | |
(expires . ,expires) (storage-class . ,storage-class)))) | |
(define (put-object! bucket key object-thunk object-length object-type . options) | |
(perform-aws-request bucket: bucket path: key verb: "PUT" content-type: object-type body: object-thunk | |
content-length: object-length no-xml: #t | |
options: (if (null? options) '() (car options)))) | |
; example | |
(let ((opts (put-options canned-acl: 'private))) | |
(put-object! "bucket" "key" thunk 10 "foo" opts) | |
(put-string! "bucket" "key" "value" opts)) | |
; making your own options | |
(put-string! "bucket" "key" "value" '((canned-acl . 'private) (metainfo . "foo"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment