将.raw文件上传到Google Cloud Storage

卡洛斯·阿奎尔·科尔特斯(Carlos AguirreCortés)

我有一个Python脚本,尝试将文件上传到Google存储上,但始终出现此错误:

googleapiclient.errors.UnknownFileType:

这是我的代码:

def create_service():

    credentials = GoogleCredentials.get_application_default()

    return build('storage', 'v1', credentials=credentials)

service=create_service()

request=service.objects().insert(bucket='testBucket',name='test.raw',media_body=path_files+file_raw)

response=request.execute()

exit()

file_raw 是一个音频.raw文件。

我正在使用的库是:

from oauth2client.client import GoogleCredentials

from googleapiclient.discovery import build

from google.cloud import storage
布兰登·雅伯(Brandon Yarbrough)

我相信,因为您的文件以“ .raw”结尾,所以“ mimetypes”库在猜测对象所需的内容类型时遇到了麻烦。尝试使用要GCS使用的MIME类型显式指定“ media_mime_type”关键字参数。

这是我认为可能会产生错误的地方:https : //github.com/google/google-api-python-client/blob/master/googleapiclient/discovery.py#L789

另外,我建议您看看适用于PythonGoogle Cloud Client库我发现它更好用。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

将 xml 文件上传到 Google Cloud Storage 时出错

使用Flask将文件上传到Google Cloud Storage

Alamofire无法将文件上传到Google Cloud Storage

将文件上传到Google Cloud Storage:500后端错误

使用 Codeigniter 将文件上传到 Google Cloud Storage

使用 For 循环将多个文件上传到 Google Cloud Storage

将文件从Firebase Cloud Functions上传到Cloud Storage

将图像从Google Cloud Function上传到Cloud Storage

将文件上传到Google Cloud Storage而不在本地下载文件?

使用Google App Engine(Python)将文件上传到Google Cloud Storage

使用Google App Engine将大文件上传到Google Cloud Storage

使用JSON API将文件上传到Google Cloud Storage,错误401未经授权

将文件直接上传到Google Cloud Storage for GAE应用

使用PHP和Ajax将文件上传到Google Cloud Storage Bucket

将Python文件上传到Google Cloud Storage Bucket返回管道中断错误

如何使用JSON API和CloseableHttpClient将文件上传到Google Cloud Storage存储桶?

使用 Node.js 将文件上传到 Google Cloud Storage(已声明“bucketName”)

使用Python将文件上传到Google Cloud Storage签名的URL

将python对象上传到Google Cloud Storage,而不保存到文件中

使用Python将文件上传到Google Cloud Storage Bucket子目录

无法从Django将文件上传到Google Cloud Storage(本地Windows ENV

从Localhost或外部服务器将文件上传到Google Cloud Storage

使用C#中的HMAC密钥将文件上传到Google Cloud Storage

如何将文件上传到 Google Cloud Storage Bucket 子目录

自动将数据上传到 Google Cloud Storage 和 BigQuery

将 Excel 上传到 Google Cloud Storage 时出错

如何通过Cloud Functions将文件上传到Cloud Storage并使用Firestore控制对Cloud Storage的访问?

使用Java通过Google App Engine将文件上传到Google Cloud Storage :(无此类文件或目录)

将 Blob 从 Firebase Storage Emulator 上传到 Firebase Cloud Storage