Skip to content

A lot of content is generated in /tmp #17

Description

@ggenzone

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.
      }
      

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions