* s3cmd, S3/S3Uri.py: Output public HTTP URL for objects
stored with Public ACL.
git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@105 830e0280-6d2a-0410-9c65-932aecc39d9d
... | ... |
@@ -33,6 +33,9 @@ class S3Uri(object): |
33 | 33 |
def __str__(self): |
34 | 34 |
return self.uri() |
35 | 35 |
|
36 |
+ def public_url(self): |
|
37 |
+ raise ValueError("This S3 URI does not have Anonymous URL representation") |
|
38 |
+ |
|
36 | 39 |
class S3UriS3(S3Uri): |
37 | 40 |
type = "s3" |
38 | 41 |
_re = re.compile("^s3://([^/]+)/?(.*)", re.IGNORECASE) |
... | ... |
@@ -59,10 +62,13 @@ class S3UriS3(S3Uri): |
59 | 59 |
def uri(self): |
60 | 60 |
return "/".join(["s3:/", self._bucket, self._object]) |
61 | 61 |
|
62 |
+ def public_url(self): |
|
63 |
+ return "http://s3.amazonaws.com/%s/%s" % (self._bucket, self._object) |
|
64 |
+ |
|
62 | 65 |
@staticmethod |
63 | 66 |
def compose_uri(bucket, object = ""): |
64 | 67 |
return "s3://%s/%s" % (bucket, object) |
65 |
- |
|
68 |
+ |
|
66 | 69 |
class S3UriS3FS(S3Uri): |
67 | 70 |
type = "s3fs" |
68 | 71 |
_re = re.compile("^s3fs://([^/]*)/?(.*)", re.IGNORECASE) |
... | ... |
@@ -130,6 +130,9 @@ def cmd_object_put(args): |
130 | 130 |
response = s3.object_put_uri(file, uri_final) |
131 | 131 |
output("File '%s' stored as %s (%d bytes)" % |
132 | 132 |
(file, uri_final, response["size"])) |
133 |
+ if Config().acl_public: |
|
134 |
+ output("Public URL of the object is: %s" % |
|
135 |
+ (uri.public_url())) |
|
133 | 136 |
|
134 | 137 |
def cmd_object_get(args): |
135 | 138 |
s3 = S3(Config()) |