예제 #1
0
    def __init__(self,
                 file_path=None,
                 file_stream=None,
                 url=None,
                 client=None,
                 chunk_size=None,
                 metadata=None,
                 retries=0,
                 retry_delay=30,
                 store_url=False,
                 url_storage=None,
                 fingerprinter=None,
                 log_func=None,
                 upload_checksum=False):
        if file_path is None and file_stream is None:
            raise ValueError(
                "Either 'file_path' or 'file_stream' cannot be None.")

        if url is None and client is None:
            raise ValueError("Either 'url' or 'client' cannot be None.")

        if store_url and url_storage is None:
            raise ValueError(
                "Please specify a storage instance to enable resumablility.")

        self.file_path = file_path
        self.file_stream = file_stream
        self.stop_at = self.file_size
        self.client = client
        self.metadata = metadata or {}
        self.store_url = store_url
        self.url_storage = url_storage
        self.fingerprinter = fingerprinter or fingerprint.Fingerprint()
        self.url = url or self.get_url()
        self.offset = self.get_offset()
        self.chunk_size = chunk_size or self.DEFAULT_CHUNK_SIZE
        self.request = None
        self.retries = retries
        self._retried = 0
        self.retry_delay = retry_delay
        self.log_func = log_func
        self.upload_checksum = upload_checksum
        self.__checksum_algorithm_name, self.__checksum_algorithm = \
            self.CHECKSUM_ALGORITHM_PAIR
예제 #2
0
    def __init__(self,
                 file_path: Optional[str] = None,
                 file_stream: Optional[IO] = None,
                 url: Optional[str] = None,
                 client: Optional['TusClient'] = None,
                 chunk_size: int = MAXSIZE,
                 metadata: Optional[Dict] = None,
                 retries: int = 0,
                 retry_delay: int = 30,
                 store_url=False,
                 url_storage: Optional[Storage] = None,
                 fingerprinter: Optional[interface.Fingerprint] = None,
                 upload_checksum=False):
        if file_path is None and file_stream is None:
            raise ValueError(
                "Either 'file_path' or 'file_stream' cannot be None.")

        if url is None and client is None:
            raise ValueError("Either 'url' or 'client' cannot be None.")

        if store_url and url_storage is None:
            raise ValueError(
                "Please specify a storage instance to enable resumablility.")

        self.file_path = file_path
        self.file_stream = file_stream
        self.stop_at = self.get_file_size()
        self.client = client
        self.metadata = metadata or {}
        self.store_url = store_url
        self.url_storage = url_storage
        self.fingerprinter = fingerprinter or fingerprint.Fingerprint()
        self.offset = 0
        self.url = None
        self.__init_url_and_offset(url)
        self.chunk_size = chunk_size
        self.retries = retries
        self.request = None
        self._retried = 0
        self.retry_delay = retry_delay
        self.upload_checksum = upload_checksum
        self.__checksum_algorithm_name, self.__checksum_algorithm = \
            self.CHECKSUM_ALGORITHM_PAIR
예제 #3
0
    def __init__(self,
                 file_path=None,
                 file_stream=None,
                 url=None,
                 client=None,
                 chunk_size=None,
                 metadata=None,
                 retries=0,
                 retry_delay=30,
                 store_url=False,
                 url_storage=None,
                 fingerprinter=None,
                 log_func=None):

        self.session = requests.Session()
        if file_path is None and file_stream is None:
            raise ValueError(
                "Either 'file_path' or 'file_stream' cannot be None.")

        if url is None and client is None:
            raise ValueError("Either 'url' or 'client' cannot be None.")

        if store_url and url_storage is None:
            raise ValueError(
                "Please specify a storage instance to enable resumablility.")

        self.file_path = file_path
        self.file_stream = file_stream
        self.stop_at = self.file_size
        self.client = client
        self.metadata = metadata or {}
        self.store_url = store_url
        self.url_storage = url_storage
        self.fingerprinter = fingerprinter or fingerprint.Fingerprint()
        self.url = url or self.get_url()
        self.offset = self.get_offset()
        self.chunk_size = chunk_size or self.DEFAULT_CHUNK_SIZE
        self.request = None
        self.retries = retries
        self._retried = 0
        self.retry_delay = retry_delay
        self.log_func = log_func
        self.http_client = TusHTTPClient(self)
예제 #4
0
 def setUp(self):
     self.fingerprinter = fingerprint.Fingerprint()