keystonejs / keystone-classic

Node.js CMS and web app framework
http://v4.keystonejs.com
MIT License
14.63k stars 2.21k forks source link

Problem with LocalStorage #4477

Open ghost opened 7 years ago

ghost commented 7 years ago

Hello good afternoon,

I'm having problems trying to get an image uploaded with FSStorage, here's my storage definition: var myStorage = new keystone.Storage({ adapter: keystone.Storage.Adapters.FS, fs: { path: keystone.expandPath('./uploads'), publicPath: '/archivos/productos/', },schema: { size: true, mimetype: true, path: true, originalname: true, url: true, }, });

And it's uploaded to Mongo correctly:

{ "_id" : ObjectId("59ed02183c03540bccc0a0f0"), "slug" : "prueba", "nombre" : "Prueba", "tipo" : "producto", "estado" : "activo", "__v" : 0, "autor" : ObjectId("59e3a2a4eccd7823d1ac93a0"), "descripcion" : { "corta" : "<p>zcxzxc</p>", "extendida" : "<p>zxczcx</p>" }, "fechaDeCreacion" : ISODate("2017-10-22T05:00:00Z"), "imagen" : { "filename" : "a-66dlsue3jSo0AD.jpg", "size" : 1270557, "mimetype" : "image/jpeg", "path" : "/Users/isaaccruz/Desktop/kyestoneGen/uploads", "originalname" : "14579490651_194962a4a4_k.jpg", "url" : "/archivos/productos/a-66dlsue3jSo0AD.jpg" }, "precio" : 2 }

But I can't manage to get the image, I've tried:

http://localhost:3000/archivos/productos/a-66dlsue3jSo0AD.jpg -404 http://localhost:3000/public/archivos/productos/a-66dlsue3jSo0AD.jpg - 404 http://localhost:3000/keystone/archivos/productos/a-66dlsue3jSo0AD.jpg - 404 http://localhost:3000/keystone/productos/archivos/productos/a-66dlsue3jSo0AD.jpg - 404

Do I have to expose a route in order to serve the image?

Is there anything else I have to do?

Thanks in advance.

milanffm commented 6 years ago

this should be the right url: http://localhost:3000/archivos/productos/a-66dlsue3jSo0AD.jpg

did you fixe the problem?

maybe you have to change this: path: keystone.expandPath('./public/uploads/')

laszlotordacsanyi commented 6 years ago

Yo Isaac. Look at the 5. line - "a-66dlsue3jSo0AD.jpg", "size" : 1270557, "mimetype" : "image/jpeg", "path" : "/Users

image/jpeg ???? image/jpg