gcsstore: Add storage details

This commit is contained in:
Marius 2019-08-19 11:08:24 +02:00
parent a323c91a6e
commit f290aa36d7
2 changed files with 19 additions and 2 deletions

View File

@ -63,6 +63,12 @@ func (store GCSStore) NewUpload(info handler.FileInfo) (id string, err error) {
info.ID = uid.Uid() info.ID = uid.Uid()
} }
info.Storage = map[string]string{
"Type": "gcsstore",
"Bucket": store.Bucket,
"Key": store.keyWithPrefix(info.ID),
}
ctx := context.Background() ctx := context.Background()
err = store.writeInfo(ctx, store.keyWithPrefix(info.ID), info) err = store.writeInfo(ctx, store.keyWithPrefix(info.ID), info)
if err != nil { if err != nil {

View File

@ -22,13 +22,18 @@ const mockBucket = "bucket"
const mockSize = 1337 const mockSize = 1337
const mockReaderData = "helloworld" const mockReaderData = "helloworld"
var mockTusdInfoJson = fmt.Sprintf(`{"ID":"%s","Size":%d,"MetaData":{"foo":"bar"}}`, mockID, mockSize) var mockTusdInfoJson = fmt.Sprintf(`{"ID":"%s","Size":%d,"MetaData":{"foo":"bar"},"Storage":{"Bucket":"bucket","Key":"%s","Type":"gcsstore"}}`, mockID, mockSize, mockID)
var mockTusdInfo = handler.FileInfo{ var mockTusdInfo = handler.FileInfo{
ID: mockID, ID: mockID,
Size: mockSize, Size: mockSize,
MetaData: map[string]string{ MetaData: map[string]string{
"foo": "bar", "foo": "bar",
}, },
Storage: map[string]string{
"Type": "gcsstore",
"Bucket": mockBucket,
"Key": mockID,
},
} }
var mockPartial0 = fmt.Sprintf("%s_0", mockID) var mockPartial0 = fmt.Sprintf("%s_0", mockID)
@ -75,7 +80,13 @@ func TestNewUploadWithPrefix(t *testing.T) {
assert.Equal(store.Bucket, mockBucket) assert.Equal(store.Bucket, mockBucket)
data, err := json.Marshal(mockTusdInfo) info := mockTusdInfo
info.Storage = map[string]string{
"Type": "gcsstore",
"Bucket": mockBucket,
"Key": "/path/to/file/" + mockID,
}
data, err := json.Marshal(info)
assert.Nil(err) assert.Nil(err)
r := bytes.NewReader(data) r := bytes.NewReader(data)