Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
matrix-media-repo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
matrix-media-repo
Commits
c8114f9b
Commit
c8114f9b
authored
5 years ago
by
Travis Ralston
Browse files
Options
Downloads
Patches
Plain Diff
Populate s3url on exports
parent
7447190b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
controllers/data_controller/export_controller.go
+6
-1
6 additions, 1 deletion
controllers/data_controller/export_controller.go
storage/datastore/ds_s3/s3_store.go
+12
-0
12 additions, 0 deletions
storage/datastore/ds_s3/s3_store.go
with
18 additions
and
1 deletion
controllers/data_controller/export_controller.go
+
6
−
1
View file @
c8114f9b
...
@@ -16,6 +16,7 @@ import (
...
@@ -16,6 +16,7 @@ import (
"github.com/turt2live/matrix-media-repo/common/config"
"github.com/turt2live/matrix-media-repo/common/config"
"github.com/turt2live/matrix-media-repo/storage"
"github.com/turt2live/matrix-media-repo/storage"
"github.com/turt2live/matrix-media-repo/storage/datastore"
"github.com/turt2live/matrix-media-repo/storage/datastore"
"github.com/turt2live/matrix-media-repo/storage/datastore/ds_s3"
"github.com/turt2live/matrix-media-repo/templating"
"github.com/turt2live/matrix-media-repo/templating"
"github.com/turt2live/matrix-media-repo/types"
"github.com/turt2live/matrix-media-repo/types"
"github.com/turt2live/matrix-media-repo/util"
"github.com/turt2live/matrix-media-repo/util"
...
@@ -183,12 +184,16 @@ func StartUserExport(userId string, s3urls bool, includeData bool, log *logrus.E
...
@@ -183,12 +184,16 @@ func StartUserExport(userId string, s3urls bool, includeData bool, log *logrus.E
}
}
mediaManifest
:=
make
(
map
[
string
]
*
manifestRecord
)
mediaManifest
:=
make
(
map
[
string
]
*
manifestRecord
)
for
_
,
m
:=
range
media
{
for
_
,
m
:=
range
media
{
s3url
,
err
:=
ds_s3
.
GetS3URL
(
m
.
DatastoreId
,
m
.
Location
)
if
err
!=
nil
{
log
.
Warn
(
err
)
}
mediaManifest
[
m
.
MxcUri
()]
=
&
manifestRecord
{
mediaManifest
[
m
.
MxcUri
()]
=
&
manifestRecord
{
ArchivedName
:
archivedName
(
m
),
ArchivedName
:
archivedName
(
m
),
FileName
:
m
.
UploadName
,
FileName
:
m
.
UploadName
,
SizeBytes
:
m
.
SizeBytes
,
SizeBytes
:
m
.
SizeBytes
,
ContentType
:
m
.
ContentType
,
ContentType
:
m
.
ContentType
,
S3Url
:
"TODO"
,
S3Url
:
s3url
,
Sha256
:
m
.
Sha256Hash
,
Sha256
:
m
.
Sha256Hash
,
Origin
:
m
.
Origin
,
Origin
:
m
.
Origin
,
MediaId
:
m
.
MediaId
,
MediaId
:
m
.
MediaId
,
...
...
This diff is collapsed.
Click to expand it.
storage/datastore/ds_s3/s3_store.go
+
12
−
0
View file @
c8114f9b
...
@@ -2,6 +2,7 @@ package ds_s3
...
@@ -2,6 +2,7 @@ package ds_s3
import
(
import
(
"context"
"context"
"fmt"
"io"
"io"
"io/ioutil"
"io/ioutil"
"os"
"os"
...
@@ -64,6 +65,17 @@ func GetOrCreateS3Datastore(dsId string, conf config.DatastoreConfig) (*s3Datast
...
@@ -64,6 +65,17 @@ func GetOrCreateS3Datastore(dsId string, conf config.DatastoreConfig) (*s3Datast
return
s3ds
,
nil
return
s3ds
,
nil
}
}
func
GetS3URL
(
datastoreId
string
,
location
string
)
(
string
,
error
)
{
var
store
*
s3Datastore
var
ok
bool
if
store
,
ok
=
stores
[
datastoreId
];
!
ok
{
return
""
,
errors
.
New
(
"s3 datastore not found"
)
}
// HACK: Surely there's a better way...
return
fmt
.
Sprintf
(
"https://%s/%s/%s"
,
store
.
conf
.
Options
[
"endpoint"
],
store
.
bucket
,
location
),
nil
}
func
(
s
*
s3Datastore
)
EnsureBucketExists
()
error
{
func
(
s
*
s3Datastore
)
EnsureBucketExists
()
error
{
found
,
err
:=
s
.
client
.
BucketExists
(
s
.
bucket
)
found
,
err
:=
s
.
client
.
BucketExists
(
s
.
bucket
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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