コード例 #1
0
def save_to_blob(local_path: str, remote_name: str,
                 container_name: str) -> None:
    # Instantiate a new BlobServiceClient using a connection string
    blob_service_client = BlobServiceClient.from_connection_string(
        connection_string)

    # Instantiate a new ContainerClient
    container_client = blob_service_client.get_container_client(container_name)

    # Ensure container is created
    # container_client.create_container()

    # Instantiate a new BlobClient
    blob_client = container_client.get_blob_client(remote_name)

    # Upload content to block blob
    # with open(local_path, "rb") as data:
    #     blob_client.upload_blob(data, timeout=600)

    # TODO do something like this instead
    block_list = []
    chunk_size = 4194304
    with open(local_path, "rb") as data:
        while True:
            read_data = data.read(chunk_size)
            if not read_data:
                break
            blk_id = uuid_to_str(uuid.uuid4())
            blob_client.stage_block(block_id=blk_id, data=read_data)
            block_list.append(BlobBlock(block_id=blk_id))
    blob_client.commit_block_list(block_list)
コード例 #2
0
ファイル: models.py プロジェクト: pietelite/pegasus
    def __init__(self,
                 file_name: str,
                 session_key: str,
                 audio_id: str = None,
                 config: dict = None,
                 available: bool = False):
        if audio_id is None:
            audio_id = uuid_to_str(uuid4())

        self.file_name = file_name
        self.session_key = session_key
        self.audio_id = audio_id
        self.config = config
        self.available = available
コード例 #3
0
ファイル: models.py プロジェクト: pietelite/pegasus
    def __init__(self,
                 video_id: str,
                 title: str,
                 description: str,
                 post_id=uuid_to_str(uuid4()),
                 created: int = None,
                 likes_count=0):
        if created is None:
            created = int(time.time())

        self.video_id = video_id
        self.title = title
        self.description = description
        self.post_id = post_id
        self.likes_count = likes_count
        self.created = created
コード例 #4
0
ファイル: models.py プロジェクト: pietelite/pegasus
    def __init__(self,
                 user_name: str,
                 password: str,
                 email: str,
                 user_id: str = None,
                 created: int = None,
                 last_online: int = None,
                 verified=False):
        if user_id is None:
            user_id = uuid_to_str(uuid4())
        if created is None:
            created = int(time.time())
        if last_online is None:
            last_online = int(time.time())

        self.user_name = user_name
        self.password = password
        self.email = email
        self.user_id = user_id
        self.created = created
        self.last_online = last_online
        self.verified = verified
コード例 #5
0
ファイル: models.py プロジェクト: pietelite/pegasus
    def __init__(self,
                 user_id: str,
                 file_type: str,
                 session_key: str,
                 video_id: str = None,
                 config: dict = None,
                 created: int = None,
                 available: bool = False):
        if video_id is None:
            video_id = uuid_to_str(uuid4())
        if created is None:
            created = int(time.time())

        self.user_id = user_id
        self.file_type = file_type
        self.session_key = session_key
        self.video_id = video_id
        self.config = config
        self.created = created
        self.available = available
        self.created_formatted = time.ctime(self.created)
        if os.path.exists(self.local_file_path()):
            self.local_url = self.local_file_url()