keystonejs/keystone-test-project

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:

  1. 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 },
        ...
    });
  2. Launch the keystone-test-project with node keystone

  3. Browse to the Post section of the CMS, create a new Post and upload a photo.

  4. Save that Post (The flash message should report that the save was successful).

  5. Now browse back to the Post listing page: http://localhost:3000/keystone/posts

  6. Click to open the Post you just saved.

  7. 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:

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!