Added support for uploads to S3 by using the boto3 client.

This commit is contained in:
Sybren A. Stüvel
2018-03-09 16:48:34 +01:00
parent 4a0673918d
commit ea832cd666
4 changed files with 207 additions and 2 deletions
+21 -2
View File
@@ -30,9 +30,9 @@ def add_parser(subparsers):
def cli_pack(args):
bpath, ppath, tpath = paths_from_cli(args)
packer = pack.Packer(bpath, ppath, tpath, args.noop)
packer.strategise()
packer = create_packer(args, bpath, ppath, tpath)
packer.strategise()
try:
packer.execute()
except blender_asset_tracer.pack.transfer.FileTransferError as ex:
@@ -41,6 +41,25 @@ def cli_pack(args):
raise SystemExit(1)
def create_packer(args, bpath: pathlib.Path, ppath: pathlib.Path,
tpath: pathlib.Path) -> pack.Packer:
if str(tpath).startswith('s3:/'):
if args.noop:
raise ValueError('S3 uploader does not support no-op.')
from blender_asset_tracer.pack import s3
# Split the target path into 's3:/', hostname, and actual target path
parts = tpath.parts
endpoint = parts[1]
tpath = pathlib.Path(*tpath.parts[2:])
log.info('Uploading to S3-compatible storage %s at %s', endpoint, tpath)
return s3.S3Packer(bpath, ppath, tpath, endpoint=endpoint)
return pack.Packer(bpath, ppath, tpath, args.noop)
def paths_from_cli(args) -> typing.Tuple[pathlib.Path, pathlib.Path, pathlib.Path]:
"""Return paths to blendfile, project, and pack target.