Skip to content

Commit

Permalink
Add ability to upload from an unbound source such as standard input o…
Browse files Browse the repository at this point in the history
…r a named pipe (Backblaze#899)
  • Loading branch information
mjurbanski-reef committed Aug 16, 2023
1 parent 6e18aaf commit 7211c98
Show file tree
Hide file tree
Showing 21 changed files with 871 additions and 152 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
* Add ability to upload from an unbound source such as standard input or a named pipe

### Deprecated
* Support of `-` as a valid filename in `upload-file` command. In future `-` will be an alias for standard input.
* Declare official support of Python 3.12
* Cache-Control option when uploading files

Expand Down
2 changes: 1 addition & 1 deletion b2/_cli/argcompleters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from functools import wraps
from itertools import islice

from b2sdk.api import B2Api
from b2sdk.v2.api import B2Api

from b2._cli.b2api import _get_b2api_for_profile
from b2._cli.const import LIST_FILE_NAMES_MAX_LIMIT
Expand Down
10 changes: 6 additions & 4 deletions b2/_cli/b2api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
import os
from typing import Optional

from b2sdk.account_info.sqlite_account_info import SqliteAccountInfo
from b2sdk.api_config import B2HttpApiConfig
from b2sdk.cache import AuthInfoCache
from b2sdk.v2 import B2Api
from b2sdk.v2 import (
AuthInfoCache,
B2Api,
B2HttpApiConfig,
SqliteAccountInfo,
)

from b2._cli.const import B2_USER_AGENT_APPEND_ENV_VAR

Expand Down
2 changes: 2 additions & 0 deletions b2/_cli/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@
B2_SOURCE_SSE_C_KEY_B64_ENV_VAR = 'B2_SOURCE_SSE_C_KEY_B64'

# Constants used in the B2 API
# TODO B2-47 move API related constants to b2sdk
CREATE_BUCKET_TYPES = ('allPublic', 'allPrivate')
DEFAULT_MIN_PART_SIZE = 5 * 1000 * 1000 # 5MB
LIST_FILE_NAMES_MAX_LIMIT = 10000 # https://www.backblaze.com/b2/docs/b2_list_file_names.html
9 changes: 9 additions & 0 deletions b2/_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
######################################################################
#
# File: b2/_utils/__init__.py
#
# Copyright 2023 Backblaze Inc. All Rights Reserved.
#
# License https://www.backblaze.com/using_b2_code.html
#
######################################################################
20 changes: 20 additions & 0 deletions b2/_utils/filesystem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
######################################################################
#
# File: b2/_utils/filesystem.py
#
# Copyright 2023 Backblaze Inc. All Rights Reserved.
#
# License https://www.backblaze.com/using_b2_code.html
#
######################################################################
import stat
from pathlib import Path


def points_to_fifo(path: Path) -> bool:
path = path.resolve()
try:

return stat.S_ISFIFO(path.stat().st_mode)
except OSError:
return False
Loading

0 comments on commit 7211c98

Please sign in to comment.