Merge of long urls pointing to PDFs failing
thaisonle opened this issue · 1 comments
I have a situation where I have files sitting in an S3/GCS bucket and need to merge certain files from that bucket. Since cloud storage isn't treated the same as local storage by gotenberg, we use temporary URLs from the bucket to merge certain files together. These temporary URLs are very long (sometimes 400+ characters) and this seems to cause an error with the gotenberg API.
$streams = collect($long_urls)->map(
fn($long_url) => Stream::path($long_url)
);
$request = Gotenberg::pdfEngines($apiUrl)
->outputFilename('requested-name')
->merge(
...$streams
);
When I run this code with the long urls, I get a Gotenberg\Exceptions\GotenbergApiErroed
error and if I check the gotenberg docker container, it says
{
"level":"error",
"ts":1641567947.0926168,
"logger":"api",
"msg":"create request context: copy to disk: create local file: open /tmp/aabf345b-68eb-457a-bbcb-728cc3813e1f/0_2021%20AR%20Help%20Manual%2010-27-2021.pdf?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAQPF2CX2ONHXT3XG3%2F20220107%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220107T150546Z&X-Amz-SignedHeaders=host&X-Amz-Expires=300&X-Amz-Signature=75620efd0a5e1c3520c398d50ea51c434b200e9785d830ddc350c14dbe714b4a: file name too long",
"trace":"2aa4913a-534a-41af-911b-90296e43adc7",
"remote_ip":"172.18.0.8",
"host":"gotenberg:3000",
"uri":"/forms/pdfengines/merge",
"method":"POST",
"path":"/forms/pdfengines/merge",
"referer":"",
"user_agent":"Symfony HttpClient/Curl",
"status":500,
"latency":5535083,
"latency_human":"5.535083ms",
"bytes_in":3083724,
"bytes_out":21
}
I'm not sure if this is because of code changes between gotenberg/gotenberg 6 => 7 or from thecodingmachine/gotenberg => gotenberg/gotenberg-php but was wondering if I could get some help.
@thaisonle Stream::path
now takes an optional $filename
argument 😄
$streams = collect($long_urls)->map(
fn($long_url) => Stream::path($long_url, 'tmp.pdf')
);