Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Convert an S3 URI path to a relative "prefix" used in the S3 API.

  • Loading branch information...
commit 8286aa67d1ff6b6ef340632a348b8fab0f9851a1 1 parent 84fbb8a
Ray Racine authored
20 aws/s3/buckets.rkt
View
@@ -1,3 +1,21 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Ray Racine's AWS API Library
+;; Copyright (C) 2007-2013 Raymond Paul Racine
+;;
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
#lang typed/racket/base
(provide
@@ -67,4 +85,4 @@
(: bucket-policy (String -> S3Response))
(define (bucket-policy bucket)
- (s3-invoke 'GET bucket "/?policy" '() '() #f))
+ (s3-invoke 'GET bucket "/?policy" '() '() #f))
25 aws/s3/uri.rkt → aws/s3/s3-uri.rkt
View
@@ -21,8 +21,7 @@
#| Helpers for S3 URI's, extracting buckets etc.|#
(provide
- s3-path->prefix
- s3-uri-bucket-and-path)
+ s3-uri-path->prefix)
(require
(only-in httpclient/uri
@@ -30,28 +29,10 @@
(only-in httpclient/uri/path
uri-path-split uri-build-path))
-(: s3-path->prefix (String -> String))
-(define (s3-path->prefix path)
+(: s3-uri-path->prefix (String -> String))
+(define (s3-uri-path->prefix path)
(if (string=? path "")
""
(if (string=? (substring path 0 1) "/")
(substring path 1)
path)))
-
-(: s3-uri-bucket-and-path (Uri -> (Values String String)))
-(define (s3-uri-bucket-and-path s3-uri)
- (let ((scheme (Uri-scheme s3-uri)))
- (if (string=? scheme "s3")
- (let ((path-segs (uri-path-split (Uri-path s3-uri))))
- (if (pair? path-segs)
- (if (string=? (car path-segs) "")
- (let ((rootless-segs (cdr path-segs)))
- (if (pair? rootless-segs)
- (values (car rootless-segs)
- (uri-build-path (cons "" (cdr rootless-segs))))
- (values "" "")))
- (values "" ""))
- (values "" "")))
- (values "" ""))))
-
-
7 aws/scribblings/manual.scrbl
View
@@ -106,6 +106,13 @@ Obtains a session token valid for the given duration in seconds from the AWS STS
@subsection{S3 API}
+@subsection{S3 URI}
+
+@defproc[(s3-uri-path->prefix [path String]) String]{
+S3 API prefixes are relative path strings to the bucket. A URI path is absolute.
+Convert a S3 Uri, s3://mybucket/a/b/c, path, "/a/b/c" to a S3 prefix "a/b/c".
+}
+
@subsection{S3 Bucket Types}
@defstruct*[Buckets ([owner Owner] [buckets (Listof Bucket)]) #:transparent]{
Please sign in to comment.
Something went wrong with that request. Please try again.