Browse code

* s3cmd: Fixed "put file.ext s3://bkt" (ie just the bucket name).

git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@383 830e0280-6d2a-0410-9c65-932aecc39d9d

Michal Ludvig authored on 2009/02/25 12:46:49
Showing 2 changed files
... ...
@@ -1,5 +1,6 @@
1 1
 2009-02-25  Michal Ludvig  <michal@logix.cz>
2 2
 
3
+	* s3cmd: Fixed "put file.ext s3://bkt" (ie just the bucket name).
3 4
 	* s3cmd: Fixed reporting of ImportError of S3 modules.
4 5
 	* s3cmd: Fixed Error: global name 'real_filename' is not defined
5 6
 
... ...
@@ -286,9 +286,11 @@ def cmd_object_put(args):
286 286
 	if len(args) == 0:
287 287
 		raise ParameterError("Nothing to upload. Expecting a local file or directory and a S3 URI destination.")
288 288
 
289
-	destination_base = args.pop()
290
-	if S3Uri(destination_base).type != 's3':
291
-		raise ParameterError("Destination must be S3Uri. Got: %s" % destination_base)
289
+	## Normalize URI to convert s3://bkt to s3://bkt/ (trailing slash)
290
+	destination_base_uri = S3Uri(args.pop())
291
+	if destination_base_uri.type != 's3':
292
+		raise ParameterError("Destination must be S3Uri. Got: %s" % destination_base_uri)
293
+	destination_base = str(destination_base_uri)
292 294
 
293 295
 	if len(args) == 0:
294 296
 		raise ParameterError("Nothing to upload. Expecting a local file or directory.")
... ...
@@ -914,7 +916,12 @@ def cmd_sync_local2remote(args):
914 914
 		error(u"or disable encryption with --no-encrypt parameter.")
915 915
 		sys.exit(1)
916 916
 
917
-	destination_base = args[-1]
917
+	## Normalize URI to convert s3://bkt to s3://bkt/ (trailing slash)
918
+	destination_base_uri = S3Uri(args[-1])
919
+	if destination_base_uri.type != 's3':
920
+		raise ParameterError("Destination must be S3Uri. Got: %s" % destination_base_uri)
921
+	destination_base = str(destination_base_uri)
922
+
918 923
 	local_list, single_file_local = fetch_local_list(args[:-1], recursive = True)
919 924
 	remote_list = fetch_remote_list(destination_base, recursive = True, require_attribs = True)
920 925