feat: add GetUploadSize
This commit is contained in:
parent
887f51f88d
commit
f3040399e4
|
@ -309,6 +309,26 @@ func (t *TusHandler) SetStorageProtocol(storageProtocol storage.StorageProtocol)
|
||||||
t.storageProtocol = storageProtocol
|
t.storageProtocol = storageProtocol
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *TusHandler) GetUploadSize(ctx context.Context, hash []byte) (int64, error) {
|
||||||
|
exists, upload := t.UploadExists(ctx, hash)
|
||||||
|
|
||||||
|
if !exists {
|
||||||
|
return 0, metadata.ErrNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
meta, err := t.tusStore.GetUpload(ctx, upload.UploadID)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info, err := meta.GetInfo(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return info.Size, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (t *TusHandler) uploadTask(hash []byte) error {
|
func (t *TusHandler) uploadTask(hash []byte) error {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
exists, upload := t.UploadExists(ctx, hash)
|
exists, upload := t.UploadExists(ctx, hash)
|
||||||
|
|
Loading…
Reference in New Issue