override public string ToString() { string result = string.Empty; if (string.IsNullOrEmpty(UploadId)) { return(string.Empty); } result += UploadId.ToString() + ContextSeparator; if (ContentMd5 == null) { ContentMd5 = string.Empty; } if (Crc64 == null) { Crc64 = string.Empty; } result += ContentMd5 + ContextSeparator + Crc64 + ContextSeparator; if (PartContextList.Count == 0) { return(string.Empty); } foreach (var part in PartContextList) { string partStr = part.ToString(); if (string.IsNullOrEmpty(partStr)) { return(string.Empty); } result += partStr + PartContextSeparator; } if (result.EndsWith(new string(PartContextSeparator, 1))) { result = result.Substring(0, result.Length - 1); } return(result); }
public async Task <string> SaveAs(bool overwrite = false, bool autoCreateDirectory = true) { var rootDir = UploadId.ToString("N"); var destination = Path.Combine(_uploadDir, DateTime.Now.ToString("yyyyMM"), rootDir.Substring(00, 02), rootDir.Substring(02, 03), /** OPTIONAL ** keep the files send with same uploadId ** united in the same folder ** rootDir.Substring(05, 27), ***/UUI.ToString("N")); if (!JoinFiles) { var directory = new DirectoryInfo(destination); destination = Path.Combine(destination, PartIndex.ToString("0000000000")); if (autoCreateDirectory) { directory.Create(); } using (var file = new FileStream(destination, overwrite ? FileMode.OpenOrCreate : FileMode.CreateNew)) { await InputStream.CopyToAsync(file); } if (TotalParts == 0) { var moveTo = Path.Combine(directory.FullName, Filename); File.Move(destination, moveTo); destination = moveTo; } } else { destination = await JoinFilesInOne(destination); } return(destination); }