Skip to content

Commit 18495a7

Browse files
authored
Fix Could not find zip member error on Serverless env (#4198)
* don't make local the temp file if running on AWS lambda * don't make local the temp file if running on AWS lambda * don't make local the temp file if running on AWS lambda * don't make local the temp file if running on AWS lambda
1 parent 2fd6e3e commit 18495a7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Writer.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,16 @@ public function reopen(TemporaryFile $tempFile, string $writerType)
143143
return $this;
144144
}
145145

146+
/**
147+
* Determine if the application is running in a serverless environment.
148+
*
149+
* @return bool
150+
*/
151+
public function isRunningServerless(): bool
152+
{
153+
return isset($_ENV['AWS_LAMBDA_RUNTIME_API']);
154+
}
155+
146156
/**
147157
* @param object $export
148158
* @param TemporaryFile $temporaryFile
@@ -166,7 +176,7 @@ public function write($export, TemporaryFile $temporaryFile, string $writerType)
166176
$export
167177
);
168178

169-
if ($temporaryFile instanceof RemoteTemporaryFile && !$temporaryFile->existsLocally()) {
179+
if ($temporaryFile instanceof RemoteTemporaryFile && !$temporaryFile->existsLocally() && !$this->isRunningServerless()) {
170180
$temporaryFile = resolve(TemporaryFileFactory::class)
171181
->makeLocal(Arr::last(explode('/', $temporaryFile->getLocalPath())));
172182
}

0 commit comments

Comments
 (0)