Ejemplo n.º 1
0
    def __init_chunked_upload(self):
        """Initialization for a multi-chunk upload."""

        # note: string conversion required here due to open encoding bug in requests-oauthlib.
        headers = {
            'x-ton-content-type':
            self.content_type,
            'x-ton-content-length':
            str(self._file_size),
            'x-ton-expires':
            http_time(self.options.get('x-ton-expires', self._DEFAULT_EXPIRE)),
            'content-length':
            str(0),
            'content-type':
            self.content_type
        }

        resource = "{0}{1}?resumable=true".format(self._DEFAULT_RESOURCE,
                                                  self._DEFAULT_BUCKET)

        return Request(self._client,
                       'post',
                       resource,
                       domain=self._DEFAULT_DOMAIN,
                       headers=headers).perform()
Ejemplo n.º 2
0
    def __upload(self, resource, bytes):
        """Performs a single chunk upload."""

        # note: string conversion required here due to open encoding bug in requests-oauthlib.
        headers = {
            'x-ton-expires': http_time(self.options.get('x-ton-expires', self._DEFAULT_EXPIRE)),
            'content-length': str(self._file_size),
            'content-type': self.content_type
        }

        return Request(self._client, 'post', resource,
                       domain=self._DEFAULT_DOMAIN, headers=headers, body=bytes).perform()
Ejemplo n.º 3
0
    def __upload(self, resource, bytes):
        """Performs a single chunk upload."""

        # note: string conversion required here due to open encoding bug in requests-oauthlib.
        headers = {
            'x-ton-expires': http_time(self.options.get('x-ton-expires', self._DEFAULT_EXPIRE)),
            'content-length': str(self._file_size),
            'content-type': self.content_type
        }

        return Request(self._client, 'post', resource,
                       domain=self._DEFAULT_DOMAIN, headers=headers, body=bytes).perform()
Ejemplo n.º 4
0
    def __init_chunked_upload(self):
        """Initialization for a multi-chunk upload."""

        # note: string conversion required here due to open encoding bug in requests-oauthlib.
        headers = {
            "x-ton-content-type": self.content_type,
            "x-ton-content-length": str(self._file_size),
            "x-ton-expires": http_time(self.options.get("x-ton-expires", self._DEFAULT_EXPIRE)),
            "content-length": str(0),
            "content-type": self.content_type,
        }

        resource = "{0}{1}?resumable=true".format(self._DEFAULT_RESOURCE, self._DEFAULT_BUCKET)

        return Request(self._client, "post", resource, domain=self._DEFAULT_DOMAIN, headers=headers).perform()