Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A lot of content is generated in /tmp #17

Open
ggenzone opened this issue Mar 9, 2023 · 0 comments
Open

A lot of content is generated in /tmp #17

ggenzone opened this issue Mar 9, 2023 · 0 comments

Comments

@ggenzone
Copy link

ggenzone commented Mar 9, 2023

The intermediate files that are downloaded are stored in /tmp, which makes it use a lot of space unnecessarily.

You could add a call to the unlink function to delete the file after use and this would improve a lot and avoid the need to go around deleting temporary files.

In this line:
https://github.com/wgenial/s3-objects-stream-zip-php/blob/master/src/S3ObjectsStreamZip.php#L69

        ....
        $tmpfile = tempnam(sys_get_temp_dir(), crc32(time()));

        $httpClient->request("GET", (string) $request->getUri(), array(
          "synchronous" => true,
          "sink" => fopen($tmpfile, "w+")
        ));
        
        if ($stream = fopen($tmpfile, "r", false, $context)) {
          $zip->addFileFromStream($objectName, $stream);
        }
        
        unlink($tmpfile);   // <-- This line will tell PHP that we no longer need the file.
      }
      
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants