Skip to content

Commit

Permalink
Fix Could not find zip member error on Serverless env (#4198)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jbajou authored Sep 7, 2024
1 parent 2fd6e3e commit 18495a7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ public function reopen(TemporaryFile $tempFile, string $writerType)
return $this;
}

/**
* Determine if the application is running in a serverless environment.
*
* @return bool
*/
public function isRunningServerless(): bool
{
return isset($_ENV['AWS_LAMBDA_RUNTIME_API']);
}

/**
* @param object $export
* @param TemporaryFile $temporaryFile
Expand All @@ -166,7 +176,7 @@ public function write($export, TemporaryFile $temporaryFile, string $writerType)
$export
);

if ($temporaryFile instanceof RemoteTemporaryFile && !$temporaryFile->existsLocally()) {
if ($temporaryFile instanceof RemoteTemporaryFile && !$temporaryFile->existsLocally() && !$this->isRunningServerless()) {
$temporaryFile = resolve(TemporaryFileFactory::class)
->makeLocal(Arr::last(explode('/', $temporaryFile->getLocalPath())));
}
Expand Down

0 comments on commit 18495a7

Please sign in to comment.