Skip to content

Go package for creating a zip archive of files on AWS S3 and upload the archive file to S3 without requiring any disk space and with limited memory.

License

Notifications You must be signed in to change notification settings

alanihre/s3zipper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

s3zipper

Go package for creating a zip archive of files on AWS S3 and upload the zip archive file to S3.

No disk space is used for this operation as the files are archived and piped directly to the zip archive file on S3 through a buffer. The full file is not stored in memory but is instead buffered to allow the application to run in limied memory environments.

Example

package main

import (
	"github.com/alanihre/s3zipper"
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"
)

func main() {
	region := "eu-north-1"

	// Create a new AWS session. Credentials stored in environment variables
	sess, err := session.NewSession(&aws.Config{
		Region: aws.String(region),
	})
	if err != nil {
		panic(err)
	}

	inputBucket := "my-s3-bucket"
	files := []string{"file1.txt", "file2.txt"}
	archiveBucket := "my-s3-bucket"
	archiveFileName := "archive.zip"

	err = s3zipper.S3Zip(sess, inputBucket, files, archiveBucket, archiveFileName)
	if err != nil {
		panic(err)
	}
}

About

Go package for creating a zip archive of files on AWS S3 and upload the archive file to S3 without requiring any disk space and with limited memory.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages