擅长:python、mysql、java
<p>如果有人在寻找同样的东西,这里是解决办法。首先,需要使用要在中创建新blob的bucket名称创建/初始化bucket变量。在此之后,如果给定的文件名不在bucket.blob(“filename”)中,则将创建一个新的blob,而不是使用bucket.blob(“filename”)调用blob。然后您可以使用blob.create_from_filename(“filename_which_you want to copy”),这将把内容复制到先前创建的blob中,以获得更详细的解决方案您可以在此处阅读blob文档:</p>
<p><a href="https://googlecloudplatform.github.io/google-cloud-python/stable/storage-blobs.html" rel="nofollow noreferrer">https://googlecloudplatform.github.io/google-cloud-python/stable/storage-blobs.html</a></p>
<p>希望这对某人有帮助。下面是示例python代码:</p>
<pre><code>client=storage.Client();
bucket=client.get_bucket('your bucket name');
blob=bucket.blob('newfile you want to create')
blob.upload_from_filename('localdirectory/filename.mp4')
</code></pre>