-
Is it possible to add_chunk to an existing file with Mojo::Asset::File? add_chunk to a non-existing file: ok
add_chunk to an existing file: bad file descriptor
On that note, what would you think about adding add_chunk to Mojo::File? add_chunk, similar to spurt, but open as append (>>):
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Your "add_chunk()" code can be written as You'll get that error message from Mojo::Asset::File when operating on existing files. I think Mojo::Asset::File is only designed to modify files if it's initialized with non-existing files. This makes sense when the webserver receives a huge body, where you the content is "new", but could be moved to a non-temporary location. https://github.com/mojolicious/mojo/blob/main/lib/Mojo/Asset/File.pm#L15 |
Beta Was this translation helpful? Give feedback.
Your "add_chunk()" code can be written as
path($file)->open('>>')->syswrite($content)
.You'll get that error message from Mojo::Asset::File when operating on existing files. I think Mojo::Asset::File is only designed to modify files if it's initialized with non-existing files. This makes sense when the webserver receives a huge body, where you the content is "new", but could be moved to a non-temporary location.
https://github.com/mojolicious/mojo/blob/main/lib/Mojo/Asset/File.pm#L15