internal B2LargeFile(B2Client b2Client, B2UnfinishedLargeFile file) { _file = file; _b2Client = b2Client; State = B2LargeFileState.New; }
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; }
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); }
private void ThrowIfNot(B2LargeFileState desiredState) { if (State != desiredState) throw new InvalidOperationException($"The B2 Large File, {FileName}, was {State} and not {desiredState} (id: {FileId})"); }
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; }