firebase - How to keep/re-create object metadata during gsutil cp on storage bucket
问题描述
I would like to sync all of the files in my Google Cloud Storage bucket with the exported files in my Firebase Storage Emulator.
- I downloaded all of my cloud files using
gsutil
to my local machine. - I used BeyondCompare to move all of the new files to the '../storage_export/blobs/ directory.
- How do I update/create the JSON metadata in '../storage_export/metadata' to reflect these new files and make them available when I run the emulator and import them in?
Edit:
The gsutil
docs mention the following:
when you download data from the cloud, it ends up in a file with no associated metadata, unless you have some way to keep or re-create that metadata.
How would one "keep" or "re-create" that metadata during a gsutil cp
download?
解决方案
You can use gsutil or the SDK to get each object's metadata and then write it down to a JSON file however, there's currently no native way to import Google Cloud Storage data in the Storage Emulator. But as I stated in my answer to this post, you can study how the emulator register the object by uploading sample files within the emulator and then running the export, you will see that the emulator will require 1 object and 1 JSON file that contains it's metadata.
Lastly, you can add the option --export-on-exit
when starting the emulator, Downloaded all data from the real Firebase project, uploaded everything with the Emulator, then kill the emulator; as stated in this post.
Note: This is not a documented feature! Firebase doesn't expose the concept of download tokens in its public SDKs or APIs, so manipulating tokens this way feels a bit "hacky". For your further reference, check this post.
推荐阅读
- bayesian - 具有组效应的二项式回归
- linux - 如何在 Linux 中使用 Maven 构建 Flink 应用程序
- angular - 将我的 Angular 应用程序转换为 PWA 时运行 http-server 命令后出错
- html - min-height 和 min-width - 它在 MDN 文档中的哪个位置告诉您这种行为?
- ssis - SSIS 包中的“没有足够的内存资源可用于完成此操作”
- c++ - 在终端中运行可执行文件与在 mac finder 中打开
- python - 如何通过python将源路径中的文件移动到目标路径?
- javascript - 浏览器从二进制字符串中读取整数
- javascript - 为数组中的值赋予属性名称
- powershell - WIX 安装程序不允许在 msiexec 命令行中使用 targetdir