New FS Storage Adapter not saving Images
Closed this issue · 3 comments
I am having a problem testing out the new FS Storage Adapter. You can recreate the problem by taking the following steps:
-
Using keystone-test-project, update
models/Post.js
to use the FS Adapter:var storage = new keystone.Storage({ adapter: keystone.Storage.Adapters.FS, fs: { path: keystone.expandPath('./uploads'), publicPath: '/public/uploads/', }, ... }); Post.add({ ... image: { type: Types.File, storage: storage }, ... });
-
Launch the keystone-test-project with
node keystone
-
Browse to the
Post
section of the CMS, create a new Post and upload a photo. -
Save that Post (The flash message should report that the save was successful).
-
Now browse back to the Post listing page: http://localhost:3000/keystone/posts
-
Click to open the Post you just saved.
-
Confirm that the Image you uploaded to the Post is not listed, nor is it saved in the
uploads
folder
I found two issues, one in the File
field that I've just fixed in Keystone master. This was crashing on upload due to a this
reference.
The second is a little more significant; It looks like the File field UI is submitting data in the wrong format. I'll fix that but in the meantime, you can use the API Test in this project to test uploading files (feel free to copy the format and add more tests, too)
To use it:
- comment out all the tests in this file except the last File one on line 9
- start this app then navigate to localhost:3000/api
Seems the upload test in test/api-react/file/1-File.js
is halted by an API error (which I opened in Issue #13). The test is halted after the call to /keystone/api/files/create
because the test is looking for a json
response, but instead it gets an Uncaught InvalidStateError
in the response.
Pretty sure this has been resolved. Please re-open if you can still replicate the issue. Thanks!