更新部署-重新部署到Google Cloud后,上传的图像将被删除 [英] updating a deployment - uploaded images gets deleted after redeployment to google cloud

查看:88
本文介绍了更新部署-重新部署到Google Cloud后,上传的图像将被删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我有一个node js网络应用程序,该网络应用程序有一个文件夹,用于存储用户从移动应用程序上传的图像.如何将图像上传到文件夹是通过使用图像的base64字符串,并使用fs.writeFile将图像保存到文件夹,例如:

So I have a node js web app, this web app has a folder to store images uploaded by users from a mobile app. How I upload the image to the folder is by using the image's base64 string, and using fs.writeFile to save the image to the folder, like this:

fs.writeFile(__dirname + '/../images/complaintImg/complaintcase_' + data.cID + '.jpg', Buffer.from(data.complaintImage, 'base64'), function (err) {
    if (err) {
        console.log(err);
    } else {
        console.log("success");
    }
});

问题是,每当将应用程序重新部署到Google Cloud时,图像都会被删除.这是因为应用程序本地版本的图像文件夹为空-当用户上传图像时,我没有该图像的本地副本.

The problem is, whenever the application is redeployed to google cloud, the images gets deleted. This is because the image folder of the local version of the application is empty - when the user uploads an image, i don't get a local copy of that image.

如何防止每次部署都删除图像?因为该应用程序会不断更新(更改js或html文件),所以我无法在每次部署中删除这些图像.如何更新部署以仅部署某些文件? gcloud app deploy 命令似乎可以部署整个项目.还是我应该将图像直接上传到Google云存储?

How do i prevent the images from getting deleted with every deployment? because the app is constantly updated (changes to js or html files), i can't have the images getting deleted with every deployment. How do i update a deployment to only deploy certain files? the gcloud app deploy command seems to deploy the entire project. or should i upload the images directly to google cloud storage?

请帮助,当前尚未将移动应用程序公开发布,因此在每次部署中删除图像仍然不是什么大问题,但是一旦公开发布就将成为一个大问题.因为它们上传的图像非常重要.预先谢谢你!

please help, currently the mobile app isn't released to the public yet, so having the images deleted with every deployment is still not a big problem now, but it will be once it's released to the public. because the images they upload are very important. thank you in advance!

推荐答案

如Dan Cornilescu的回答所述,对于用户上传的文件,您应该将它们存储在Cloud Storage中,用于

As stated in Dan Cornilescu's answer, for user uploaded files, you should store them in Cloud Storage for GAE Standard or for GAE Flexible.

仅供参考,对于使用Python 2.7,Java 8或PHP 5的用户,还有一个替代方法,即

Just as a reference, there is an alternative for those who are using Python 2.7, Java 8 or PHP 5, which is the BlobStore API

这篇关于更新部署-重新部署到Google Cloud后,上传的图像将被删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆