gcsstore: Add storage details
This commit is contained in:
parent
a323c91a6e
commit
f290aa36d7
|
@ -63,6 +63,12 @@ func (store GCSStore) NewUpload(info handler.FileInfo) (id string, err error) {
|
|||
info.ID = uid.Uid()
|
||||
}
|
||||
|
||||
info.Storage = map[string]string{
|
||||
"Type": "gcsstore",
|
||||
"Bucket": store.Bucket,
|
||||
"Key": store.keyWithPrefix(info.ID),
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
err = store.writeInfo(ctx, store.keyWithPrefix(info.ID), info)
|
||||
if err != nil {
|
||||
|
|
|
@ -22,13 +22,18 @@ const mockBucket = "bucket"
|
|||
const mockSize = 1337
|
||||
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{
|
||||
ID: mockID,
|
||||
Size: mockSize,
|
||||
MetaData: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
Storage: map[string]string{
|
||||
"Type": "gcsstore",
|
||||
"Bucket": mockBucket,
|
||||
"Key": mockID,
|
||||
},
|
||||
}
|
||||
|
||||
var mockPartial0 = fmt.Sprintf("%s_0", mockID)
|
||||
|
@ -75,7 +80,13 @@ func TestNewUploadWithPrefix(t *testing.T) {
|
|||
|
||||
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)
|
||||
|
||||
r := bytes.NewReader(data)
|
||||
|
|
Loading…
Reference in New Issue