allow subpaths inside zipfiles
This commit is contained in:
parent
76a16e6ba6
commit
b7185bc313
2 changed files with 32 additions and 9 deletions
|
@ -65,11 +65,11 @@ async def file_loader(files):
|
|||
file_progress.update(len(data))
|
||||
yield data
|
||||
|
||||
async def send(paths, host, password, lifetime, collection_name=None):
|
||||
async def send(paths, host, password, lifetime, collection_name=None, relpaths=False):
|
||||
paths = [path for path in paths if path.is_file()]
|
||||
fileMetadata = [
|
||||
{
|
||||
"name": path.name,
|
||||
"name": str(path) if relpaths else path.name,
|
||||
"size": path.stat().st_size,
|
||||
"modtime": math.floor(path.stat().st_mtime * 1000),
|
||||
} for path in paths
|
||||
|
@ -97,6 +97,7 @@ parser = argparse.ArgumentParser(description="Upload files to transbeam")
|
|||
parser.add_argument("-l", "--lifetime", type=int, default=7, help="Lifetime in days for files (default 7)")
|
||||
parser.add_argument("-H", "--host", type=str, default="transbeam.link", help="transbeam host (default transbeam.link)")
|
||||
parser.add_argument("-n", "--collection-name", type=str, help="Name for a collection of multiple files")
|
||||
parser.add_argument("-R", "--relative-paths", action="store_true", help="Preserve file paths relative to working directory")
|
||||
parser.add_argument("files", type=pathlib.Path, nargs="+", help="Files to upload")
|
||||
|
||||
async def main():
|
||||
|
@ -105,6 +106,6 @@ async def main():
|
|||
print("--collection-name is only applicable when multiple files are being uploaded")
|
||||
exit(1)
|
||||
password = getpass.getpass()
|
||||
await send(args.files, args.host, password, args.lifetime, args.collection_name)
|
||||
await send(args.files, args.host, password, args.lifetime, args.collection_name, args.relative_paths)
|
||||
|
||||
asyncio.run(main())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue