如何修复Google Cloud Storage中流阅读过去的模板?

时间:2019-05-01 00:26:47

标签: python google-cloud-storage

我正在尝试使用python将文件(82 MB)上传到区域性gcloud存储桶,但出现以下错误:

File "C:\PROGRA~2\Google\CLOUDS~1\p2\lib\site-packages\google\resumable_media\_upload.py", line 825, in get_next_chunk
raise ValueError(msg) 
ValueError: 61079552 bytes have been read from the stream, which exceeds the expected total 54525952.

那是我正在使用的代码:

import os 
from google.cloud import storage

def upload_to_gcloud(bucket_name, source_file_name, destination_blob_name):
    storage_client = storage.Client()
    bucket = storage_client.get_bucket(bucket_name)
    blob = bucket.blob(destination_blob_name)
    blob.upload_from_filename(source_file_name)

def process(mp4_file):
    def strip(text, suffix):
        if not text.endswith(suffix):
            return text
        return text[:len(text) - len(suffix)]

    stripped_name = strip(mp4_file, ".mp4")
    audio_file = stripped_name + ".raw"
    cmd = ("ffmpeg -i " + mp4_file + " -y -loglevel quiet -ac 1 -f s16le -acodec pcm_s16le -vn " + audio_file)#
    os.popen(cmd)
    print (os.path.basename(audio_file))
    return stripped_name

audio_file_path = process(mp4_file) 
audio_file = audio_file_path + ".raw"
audio_file_name = os.path.basename(audio_file_path) + '.raw'    
upload_to_gcloud(bucket, source_file_name=audio_file, destination_blob_name=audio_file_name)

0 个答案:

没有答案