Skip to content

Commit

Permalink
few misc things
Browse files Browse the repository at this point in the history
  • Loading branch information
leafo committed Nov 22, 2023
1 parent f539cb1 commit 0438203
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions zipserver/copy_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ func copyHandler(w http.ResponseWriter, r *http.Request) error {
storage, err := NewGcsStorage(config)

if storage == nil {
log.Fatal("Failed to create storage: ", err)
log.Fatal("Failed to create source (GCS) storage: ", err)
}

targetStorage, err := NewS3Storage(config)

if storage == nil {
log.Fatal("Failed to create storage: ", err)
log.Fatal("Failed to create target (S3) storage: ", err)
}

startTime := time.Now()
Expand Down
4 changes: 4 additions & 0 deletions zipserver/mem_storage.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package zipserver

// MemStorage implements Storage interface in memory, storing objects in a map.
// This is used for the serving of a zip file over http. Keep in mind extracted
// zips are stored forever, this should only be used for testing or one-off use

import (
"bytes"
"context"
Expand Down
15 changes: 15 additions & 0 deletions zipserver/s3_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,18 @@ func (c *S3Storage) HeadFile(ctx context.Context, bucket, key string) (url.Value

return out, nil
}

func (c *S3Storage) DeleteFile(ctx context.Context, bucket, key string) error {
svc := s3.New(c.Session)
input := &s3.DeleteObjectInput{
Bucket: aws.String(bucket),
Key: aws.String(key),
}

_, err := svc.DeleteObjectWithContext(ctx, input)
if err != nil {
return err
}

return nil
}

0 comments on commit 0438203

Please sign in to comment.