Skip to content

Commit

Permalink
add: ingest license data from sbom (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
genos1998 authored Nov 27, 2024
1 parent b9e702d commit 9078ff0
Show file tree
Hide file tree
Showing 6 changed files with 4,332 additions and 1 deletion.
24 changes: 24 additions & 0 deletions graphqlFunc/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"crypto/tls"
"fmt"
"io"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -105,3 +106,26 @@ func (u *S3Client) upload(ctx context.Context, bucketName, key string, outfile *
})
return err
}

func (u *S3Client) ObjectExists(ctx context.Context, bucketName string, key string) bool {
_, err := u.S3Client.HeadObject(ctx, &s3.HeadObjectInput{
Bucket: aws.String(bucketName),
Key: aws.String(key),
})
return err == nil
}

const (
partMBS = int64(10) // size of chunks to upload/download
)

func (u *S3Client) Download(ctx context.Context, bucketName string, key string, dst io.WriterAt) error {
downloader := manager.NewDownloader(u.S3Client, func(u *manager.Downloader) {
u.PartSize = partMBS * 1024 * 1024
})
_, err := downloader.Download(ctx, dst, &s3.GetObjectInput{
Bucket: aws.String(bucketName),
Key: aws.String(key),
})
return err
}
Loading

0 comments on commit 9078ff0

Please sign in to comment.