Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bobgroup-go-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bob Public Utils
bobgroup-go-utils
Commits
ed571691
Commit
ed571691
authored
3 years ago
by
Johan de Klerk
Browse files
Options
Downloads
Patches
Plain Diff
S3: Set expiry duration
parent
75d7999f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
s3/s3.go
+11
-5
11 additions, 5 deletions
s3/s3.go
with
11 additions
and
5 deletions
s3/s3.go
+
11
−
5
View file @
ed571691
...
...
@@ -249,14 +249,14 @@ func (s SessionWithHelpers) GetObjectMetadata(bucket string, fileName string, is
}
// MoveObjectBucketToBucket - Move object from one S3 bucket to another
func
(
s
SessionWithHelpers
)
MoveObjectBucketToBucket
(
sourceBucket
string
,
destinationBucket
string
,
sourceFileName
string
,
destinationFileName
string
,
isDebug
bool
)
error
{
func
(
s
SessionWithHelpers
)
MoveObjectBucketToBucket
(
sourceBucket
string
,
destinationBucket
string
,
sourceFileName
string
,
destinationFileName
string
,
settings
S3UploadSettings
)
error
{
err
:=
s
.
CopyObjectBucketToBucket
(
sourceBucket
,
destinationBucket
,
sourceFileName
,
destinationFileName
,
isDebug
)
err
:=
s
.
CopyObjectBucketToBucket
(
sourceBucket
,
destinationBucket
,
sourceFileName
,
destinationFileName
,
settings
)
if
err
!=
nil
{
return
err
}
err
=
s
.
DeleteObjectFromBucket
(
sourceBucket
,
sourceFileName
,
isDebug
)
err
=
s
.
DeleteObjectFromBucket
(
sourceBucket
,
sourceFileName
)
if
err
!=
nil
{
return
err
}
...
...
@@ -265,7 +265,7 @@ func (s SessionWithHelpers) MoveObjectBucketToBucket(sourceBucket string, destin
}
// CopyObjectBucketToBucket - Copy an object from one S3 bucket to another
func
(
s
SessionWithHelpers
)
CopyObjectBucketToBucket
(
sourceBucket
string
,
destinationBucket
string
,
sourceFileName
string
,
destinationFilename
string
,
isDebug
bool
)
error
{
func
(
s
SessionWithHelpers
)
CopyObjectBucketToBucket
(
sourceBucket
string
,
destinationBucket
string
,
sourceFileName
string
,
destinationFilename
string
,
settings
S3UploadSettings
)
error
{
// copy the file
copySource
:=
url
.
QueryEscape
(
sourceBucket
+
"/"
+
sourceFileName
)
copyObjectInput
:=
&
s3
.
CopyObjectInput
{
...
...
@@ -273,6 +273,12 @@ func (s SessionWithHelpers) CopyObjectBucketToBucket(sourceBucket string, destin
CopySource
:
aws
.
String
(
copySource
),
// source path (ie: myBucket/myFile.csv)
Key
:
aws
.
String
(
destinationFilename
),
// filename on destination
}
if
settings
.
ExpiryDuration
!=
nil
{
expiry
:=
time
.
Now
()
.
Add
(
*
settings
.
ExpiryDuration
)
copyObjectInput
.
Expires
=
&
expiry
}
_
,
err
:=
s
.
S3Session
.
CopyObject
(
copyObjectInput
)
if
err
!=
nil
{
return
err
...
...
@@ -288,7 +294,7 @@ func (s SessionWithHelpers) CopyObjectBucketToBucket(sourceBucket string, destin
}
// DeleteObjectFromBucket - Delete an object from an S3 bucket
func
(
s
SessionWithHelpers
)
DeleteObjectFromBucket
(
bucket
string
,
fileName
string
,
isDebug
bool
)
error
{
func
(
s
SessionWithHelpers
)
DeleteObjectFromBucket
(
bucket
string
,
fileName
string
)
error
{
// delete the file
deleteObjectInput
:=
&
s3
.
DeleteObjectInput
{
Bucket
:
aws
.
String
(
bucket
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment