Keystone JS:使用临时字符串自动重命名S3图像上传 [英] Keystone JS: S3 image uploads being auto-renamed with temporary string

查看:73
本文介绍了Keystone JS:使用临时字符串自动重命名S3图像上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Keystone很陌生,因为我最近在一个使用它的项目上继承了一个代码库。我们被锁定到版本0.2.42所以我刚刚更新到最新版本0.3.12,现在我遇到了一个奇怪的问题。我们所有带有图像的模型都使用S3进行上传(Types.S3File),它只是将原始文件名的图像放在指定S3存储桶的根目录下。但是,现在,正在重命名文件,我猜测它是一个临时字符串名称。例如,如果我上传名为MyImage.jpg的文件,它将上传为7830c3a6bc7b6790e63de9a3c3716b06.jpg。我需要编辑一个新配置来保留原始文件名吗?谢谢你的帮助。

I'm pretty new to Keystone as I recently inherited a codebase on a project that used it. We were locked into version 0.2.42 so I just updated to the latest, version 0.3.12 and now I'm having a strange issue. All our models with images use S3 for upload (Types.S3File) and it used to just place the image with the original file name at the root of the specified S3 bucket. Now, however, the files are being renamed with what I'm guessing is a temporary string name. For example if I upload a file called "MyImage.jpg," it will upload as something like "7830c3a6bc7b6790e63de9a3c3716b06.jpg." Is there a new configuration I need to edit to retain the original file name as used to be the case? Thank you for your help.

Seth

推荐答案

我想这个在Github上给了一点帮助所以我想我会在这里回答我自己的问题。

I figured this out with a bit of help over on Github so I figured I'd answer my own question here.

前一个程序员编写的PostKeystone列表只有为图像字段定义的类型。我还添加了文件名选项:

The "Post" Keystone list that the previous programmer had written only had type defined for the image field. I added that filename option as well:

image: {
    type: Types.S3File,
    filename: function(item, filename, originalname){
        return originalname;
    }
},

现在保留原始文件名。

这篇关于Keystone JS:使用临时字符串自动重命名S3图像上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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