scripts/upload_services/transferwee.py
def _upload_chunks(transfer_id: str, file_id: str, file: str,
                   session: requests.Session,
                   default_chunk_size: int = WETRANSFER_DEFAULT_CHUNK_SIZE) -> str:
    """Given a transfer_id, file_id and file upload it.

    Return the parsed JSON response.
    """
    f = open(file, 'rb')

    chunk_number = 0
    while True:
        chunk = f.read(default_chunk_size)
        chunk_size = len(chunk)
        if chunk_size == 0:
            break
        chunk_number += 1

        j = {
            "chunk_crc": zlib.crc32(chunk),
            "chunk_number": chunk_number,
            "chunk_size": chunk_size,
            "retries": 0
        }

        r = session.post(
            WETRANSFER_PART_PUT_URL.format(transfer_id=transfer_id,
                                           file_id=file_id),
            json=j)
        url = r.json().get('url')
        requests.options(url,
                             headers={
                                 'Origin': 'https://wetransfer.com',
                                 'Access-Control-Request-Method': 'PUT',
                             })
        requests.put(url, data=chunk)

    j = {
        'chunk_count': chunk_number
    }
    r = session.put(
        WETRANSFER_FINALIZE_MPP_URL.format(transfer_id=transfer_id,
                                           file_id=file_id),
        json=j)

    return r.json()
Given a transfer_id, file_id and file upload it.

    Return the parsed JSON response.
    
Given a transfer_id, file_id and file upload it.
Return the parsed JSON response.
Given a transfer_id file_id and file upload it . Return the parsed JSON response .
def _upload_chunks(transfer_id: str, file_id: str, file: str,
                   session: requests.Session,
                   default_chunk_size: int = WETRANSFER_DEFAULT_CHUNK_SIZE) -> str:
    f = open(file, 'rb')
    chunk_number = 0
    while True:
        chunk = f.read(default_chunk_size)
        chunk_size = len(chunk)
        if chunk_size == 0:
            break
        chunk_number += 1
        j = {
            "chunk_crc": zlib.crc32(chunk),
            "chunk_number": chunk_number,
            "chunk_size": chunk_size,
            "retries": 0
        }
        r = session.post(
            WETRANSFER_PART_PUT_URL.format(transfer_id=transfer_id,
                                           file_id=file_id),
            json=j)
        url = r.json().get('url')
        requests.options(url,
                             headers={
                                 'Origin': 'https://wetransfer.com',
                                 'Access-Control-Request-Method': 'PUT',
                             })
        requests.put(url, data=chunk)
    j = {
        'chunk_count': chunk_number
    }
    r = session.put(
        WETRANSFER_FINALIZE_MPP_URL.format(transfer_id=transfer_id,
                                           file_id=file_id),
        json=j)
    return r.json()
def _upload_chunks ( transfer_id : str , file_id : str , file : str , session : requests . Session , default_chunk_size : int = WETRANSFER_DEFAULT_CHUNK_SIZE ) -> str : f = open ( file , 'rb' ) chunk_number = 0 while True : chunk = f . read ( default_chunk_size ) chunk_size = len ( chunk ) if chunk_size == 0 : break chunk_number += 1 j = { "chunk_crc" : zlib . crc32 ( chunk ) , "chunk_number" : chunk_number , "chunk_size" : chunk_size , "retries" : 0 } r = session . post ( WETRANSFER_PART_PUT_URL . format ( transfer_id = transfer_id , file_id = file_id ) , json = j ) url = r . json ( ) . get ( 'url' ) requests . options ( url , headers = { 'Origin' : 'https://wetransfer.com' , 'Access-Control-Request-Method' : 'PUT' , } ) requests . put ( url , data = chunk ) j = { 'chunk_count' : chunk_number } r = session . put ( WETRANSFER_FINALIZE_MPP_URL . format ( transfer_id = transfer_id , file_id = file_id ) , json = j ) return r . json ( )
Given a transfer_id, file_id and file upload it.
Given a transfer_id file_id and file upload it .
"""Given a transfer_id, file_id and file upload it.

    Return the parsed JSON response.
    """
transfer_id
str
file_id
str
file
str
session
requests.Session
default_chunk_size
int