Exemplo n.º 1
0
        internal B2LargeFile(B2Client b2Client, B2UnfinishedLargeFile file)
        {
            _file = file;
            _b2Client = b2Client;

            State = B2LargeFileState.New;
        }
Exemplo n.º 2
0
        internal B2LargeFile(B2Client b2Client, B2FileInfo file)
        {
            _file = new B2UnfinishedLargeFile
            {
                AccountId = file.AccountId,
                BucketId = file.BucketId,
                FileName = file.FileName,
                ContentType = file.ContentType,
                FileId = file.FileId,
                FileInfo = file.FileInfo,
                UploadTimestamp = file.UploadTimestamp
            };
            _b2Client = b2Client;

            State = B2LargeFileState.New;
        }
Exemplo n.º 3
0
        public async Task<B2File> FinishAsync(List<string> sha1Hashes)
        {
            ThrowIfNot(B2LargeFileState.New);

            B2FileInfo result = await _b2Client.Communicator.FinishLargeFileUpload(FileId, sha1Hashes);

            State = B2LargeFileState.Finished;

            _b2Client.MarkLargeFileDone(FileId);

            return new B2File(_b2Client, result);
        }
Exemplo n.º 4
0
 private void ThrowIfNot(B2LargeFileState desiredState)
 {
     if (State != desiredState)
         throw new InvalidOperationException($"The B2 Large File, {FileName}, was {State} and not {desiredState} (id: {FileId})");
 }
Exemplo n.º 5
0
        public override async Task<bool> DeleteAsync()
        {
            ThrowIfNot(B2LargeFileState.New);

            bool res = await _b2Client.Communicator.DeleteFile(FileName, FileId);
            State = B2LargeFileState.Deleted;

            _b2Client.MarkLargeFileDone(FileId);

            return res;
        }