Closed jonasoberschweiber closed 2 years ago
That solution makes sense to me as a PR to shrine ... I think shrine can handle having no extracted filename already? @janko , good PR? @jonasoberschweiber , if the maintainers like it, are you interested in making a PR with a test?
Brief Description
Attaching an unlinked Tempfile using
Attacher#attach
fails with a TypeError.Expected behavior
attach
should attach the Tempfile.Actual behavior
In
extract_filename
, Shrine passes the Tempfile'spath
, which is nil, toFile::basename
.basename
fails because it doesn't expect nil.When a Tempfile is unlinked, its
path
is set to nil, but its contents remain accessible. This is valid on POSIX systems and it's what Puma does for request bodies beyond a certain size. We're trying to attachrequest.body
in an API handler.For now, I've monkeypatched
extract_filename
like this. It seems to work, but I'm not sure if it's the optimal solution.Simplest self-contained example code to demonstrate issue
System configuration
Ruby version: Reproduced on 2.7.5
Shrine version: 3.4.0