__init__.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:pillar 作者: armadillica 项目源码 文件源码
def stream_to_gcs(file_id: ObjectId, file_size: int, internal_fname: str, project_id: ObjectId,
                  stream_for_gcs: FileType, content_type: str) \
        -> typing.Tuple[GoogleCloudStorageBlob, GoogleCloudStorageBucket]:
    # Upload the file to GCS.
    try:
        bucket = GoogleCloudStorageBucket(str(project_id))
        blob = bucket.blob(internal_fname)
        blob.create_from_file(stream_for_gcs, file_size=file_size, content_type=content_type)
    except Exception:
        log.exception('Error uploading file to Google Cloud Storage (GCS),'
                      ' aborting handling of uploaded file (id=%s).', file_id)
        update_file_doc(file_id, status='failed')
        raise wz_exceptions.InternalServerError(
            'Unable to stream file to Google Cloud Storage')

    return blob, bucket
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号