keystonejs/keystone-classic

generateFilename not working for cloudinaryimage type

Open

#4568 opened on Feb 7, 2018

View on GitHub
 (1 comment) (0 reactions) (1 assignee)JavaScript (14,656 stars) (2,288 forks)batch import
4.x candidatebughelp wanted

Description

Hi Guys, I'm just here to report a bug. The "generateFilename" function for cloudinaryImage type does not work for me and causes the admin UI to hang for ages until eventually failing to upload to cloudinary. The admin UI then giving me an empty error message as I can only see a red box at top of admin UI (where you usually get error messages such as "invalid crf").

I am using the method described in: https://github.com/keystonejs/keystone/tree/master/fields/types/cloudinaryimage

And this is my code:

image: { type: Types.CloudinaryImage, generateFilename: function(file, attemptNumber, callback) { var originalname = file.originalname; var filenameWithoutExtension = originalname.substring(0, originalname.lastIndexOf('.')); var timestamp = new Date().getTime(); return ${filenameWithoutExtension}-${timestamp}; }, }

My cloudinary setting for upload have auto-create folders ON and i tried with Use file name in "Media Library" ON and OFF. No luck.

Thank you.

Expected behavior

Able to generate cloudinaryimage filename and using this filename as name of image on cloudinary rather than just random string as filename by using the generateFilename method explained here: https://github.com/keystonejs/keystone/tree/master/fields/types/cloudinaryimage

Actual/Current behavior

The admin UI is stuck with "Save" but changed to "saving..." but it hangs there for ages until eventually failing to upload to cloudinary. The admin UI then giving me an empty error message as I can only see a red box at top of admin UI (where you usually get error messages such as "invalid crf"). keystone-bug

Steps to reproduce the actual/current behavior

Try to create a cloudinary image type field in post.js and use generatefilename method describe in readme for cloudinaryimage ongithub, so this code: image: { type: Types.CloudinaryImage, generateFilename: function(file, attemptNumber, callback) { var originalname = file.originalname; var filenameWithoutExtension = originalname.substring(0, originalname.lastIndexOf('.')); var timestamp = new Date().getTime(); return ${filenameWithoutExtension}-${timestamp}; }, }

Environment

Software Version
Keystone 4.0.0-beta.5
Node v8.9.4

Contributor guide