-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Felix Breidenstein
committed
Oct 19, 2021
1 parent
9a48dc3
commit 4e90c72
Showing
6 changed files
with
275 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
s3-http-proxy | ||
dist/ | ||
cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package main | ||
|
||
import ( | ||
"io" | ||
"os" | ||
|
||
"github.com/aws/aws-sdk-go/service/s3" | ||
) | ||
|
||
// FileWrapper wraps either a local file or an reponse from S3 | ||
// It either contains a pointer to a local file and the reponse from a HeadObject request | ||
// or both of these are nil and it only contains an GetObject request | ||
type FileWrapper struct { | ||
File *os.File | ||
GetOutput *s3.GetObjectOutput | ||
HeadOutput *s3.HeadObjectOutput | ||
} | ||
|
||
func (obj *FileWrapper) GetContent() io.Reader { | ||
if obj.File != nil { | ||
return obj.File | ||
} else { | ||
return obj.GetOutput.Body | ||
} | ||
} | ||
|
||
func (obj *FileWrapper) GetContentType() string { | ||
if obj.GetOutput != nil { | ||
return *obj.GetOutput.ContentType | ||
} else { | ||
return *obj.HeadOutput.ContentType | ||
} | ||
} | ||
|
||
func (obj *FileWrapper) GetMetadata() map[string]*string { | ||
if obj.GetOutput != nil { | ||
return obj.GetOutput.Metadata | ||
} else { | ||
return obj.HeadOutput.Metadata | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters