Closed msrdic closed 2 years ago
I actually did investigate and found where the split()
is being called. It's in a place where extension is being extracted from the name that is returned in the response. I forked the repository, but since I see no tests and I am not a JS developer, I don't feel confident enough submitting the pull request or making a design decision regarding this.
In addition to this, optional fields from the backend response are not saved at all.
The attach plugin only takes the fields url
, name
and size
into account, but not any others [1].
In comparison, the image plugin copies the whole backend response object instead [2].
[1] https://github.com/editor-js/attaches/blob/0e246b8f6899b7bd4380147a1ec73df22be1dff1/src/index.js#L256 [2] https://github.com/editor-js/image/blob/4ccb865d876d87edfa60f620136984eff73ebc12/src/index.js#L346
I am facing the same problem and it would be helpful if fix it
I have fixed this in my fork along with some other stuff to make this plugin a bit more aligned with @editorjs/image. But I'm not sure if it meets the quality standards of this codebase. Anyway, feel free to use this to create a PR or merge if you like.
In the section about backend response format, the text says
I've implemented a simple upload handler which returns only
{ success : 1 }
response, but the component fails with the messageThe same thing happens when I add an empty
file: { }
section to response.If I add the
url
field insidefile
object, the error changes toThe message is the same if I add the
title
field inside thefile
object.Once I added the
name
field into thefile
object, everything works as expected.Note that in all these instances, the actual upload works – the file is properly stored inside the dedicated uploads folder.
I am using the latest dist version downloaded from the master branch today.
The way I see it, either docs need to reflect that
name
is a required response field inside thefile
object, or it needs to default to some name if one isn't returned.Happy to supply more details if needed and thank you for all your work on this.