| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | ! Copyright (C) 2009 Chris Double. | 
					
						
							|  |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							|  |  |  | USING: assocs help.markup help.syntax kernel strings ;
 | 
					
						
							|  |  |  | IN: s3 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: buckets | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | { $values | 
					
						
							|  |  |  |   { "seq" "a sequence of " { $link bucket } " objects" } | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | { $description | 
					
						
							| 
									
										
										
										
											2015-08-06 18:05:12 -04:00
										 |  |  |     "Returns a list of " { $link bucket } " objects containing data on the buckets available on S3." } | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | { $examples | 
					
						
							|  |  |  |   { $unchecked-example "USING: s3 ;" "buckets ." "{ }" } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: create-bucket | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | { $values | 
					
						
							|  |  |  |   { "bucket" string } | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | { $description | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  |     "Creates a bucket with the given name." | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | { $examples | 
					
						
							|  |  |  |   { $unchecked-example "USING: s3 ;" "\"testbucket\" create-bucket" "" } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: delete-bucket | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | { $values | 
					
						
							|  |  |  |   { "bucket" string } | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | { $description | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  |     "Deletes the bucket with the given name." | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | { $examples | 
					
						
							|  |  |  |   { $unchecked-example "USING: s3 ;" "\"testbucket\" delete-bucket" "" } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: keys | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | { $values | 
					
						
							|  |  |  |   { "bucket" string } | 
					
						
							| 
									
										
										
										
											2015-08-06 18:05:12 -04:00
										 |  |  |   { "seq" "a sequence of " { $link key } " objects" } | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | { $description | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  |     "Returns a sequence of " { $link key } " objects. Each object in the sequence has information about the keys contained within the bucket." | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | { $examples | 
					
						
							|  |  |  |   { $unchecked-example "USING: s3 ;" "\"testbucket\" keys . " "{ }" } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: get-object | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | { $values | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  |   { "bucket" string } | 
					
						
							|  |  |  |   { "key" string } | 
					
						
							| 
									
										
										
										
											2015-08-06 18:05:12 -04:00
										 |  |  |   { "response" "The HTTP response object" } | 
					
						
							|  |  |  |   { "data" "The data returned from the http request" } | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | { $description | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  |     "Does an HTTP request to retrieve the object in the bucket with the given key." | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | { $examples | 
					
						
							|  |  |  |   { $unchecked-example "USING: s3 ;" "\"testbucket\" \"mykey\" http-get " "" } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: put-object | 
					
						
							|  |  |  | { $values | 
					
						
							|  |  |  |   { "data" object } | 
					
						
							|  |  |  |   { "mime-type" string } | 
					
						
							|  |  |  |   { "bucket" string } | 
					
						
							|  |  |  |   { "key" string } | 
					
						
							|  |  |  |   { "headers" assoc } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | { $description | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  |     "Stores the object under the key in the given bucket. The object has " | 
					
						
							|  |  |  | "the given mimetype. 'headers' should contain key/values for any headers to " | 
					
						
							|  |  |  | "be associated with the object. 'data' is any Factor object that can be " | 
					
						
							|  |  |  | "used as the 'data' slot in <post-data>. If it's a <pathname> it stores " | 
					
						
							|  |  |  | "the contents of the file. If it's a stream, it's the contents of the " | 
					
						
							|  |  |  | "stream, etc." | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | { $examples | 
					
						
							|  |  |  |   { $unchecked-example "USING: s3 ;" "\"hello\" binary encode \"text/plain\" \"testbucket\" \"hello.txt\" H{ { \"x-amz-acl\" \"public-read\" } } put-object" "" } | 
					
						
							|  |  |  |   { $unchecked-example "USING: s3 ;" "\"hello.txt\" <pathname> \"text/plain\" \"testbucket\" \"hello.txt\" H{ { \"x-amz-acl\" \"public-read\" } } put-object" "" } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: delete-object | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | { $values | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  |   { "bucket" string } | 
					
						
							|  |  |  |   { "key" string } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | { $description | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  |     "Deletes the object in the bucket with the given key." | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | { $examples | 
					
						
							|  |  |  |   { $unchecked-example "USING: s3 ;" "\"testbucket\" \"mykey\" delete-object" "" } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ARTICLE: "s3" "Amazon S3" | 
					
						
							|  |  |  | "The " { $vocab-link "s3" } " vocabulary provides a wrapper to the Amazon " | 
					
						
							|  |  |  | "Simple Storage Service API." | 
					
						
							|  |  |  | $nl | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | "To use the api you must set the variables " { $link key-id } " and " | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | { $link secret-key } " to your Amazon S3 key and secret key respectively. Once " | 
					
						
							|  |  |  | "this is done you can call any of the words below." | 
					
						
							|  |  |  | { $subsections buckets | 
					
						
							|  |  |  |     create-bucket | 
					
						
							|  |  |  |     delete-bucket | 
					
						
							|  |  |  |     keys
 | 
					
						
							|  |  |  |     get-object | 
					
						
							|  |  |  |     put-object | 
					
						
							|  |  |  |     delete-object | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ABOUT: "s3" |