Keystone JS: S3 image uploads being auto-renamed with temporary string

醉酒当歌 提交于 2019-12-02 21:15:40

问题


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


回答1:


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

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;
    }
},

The original file name is now preserved.



来源:https://stackoverflow.com/questions/31524442/keystone-js-s3-image-uploads-being-auto-renamed-with-temporary-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!