private static void FillFileLengths(IBlobStorageManager storage, PatientFilesGroupViewModel viewModel, int?dbUserId) { // reading file sizes from the storage // todo: use db to get file size (faster) foreach (var eachFile in viewModel.Files) { var fullStoragePath = string.Format("{0}\\{1}", eachFile.ContainerName, eachFile.BlobName); var mustStartWith = string.Format("patient-files-{0}\\", dbUserId); if (!fullStoragePath.StartsWith(mustStartWith)) { continue; } eachFile.FileLength = storage.GetFileLength(eachFile.ContainerName, eachFile.BlobName); } }
/// <summary> /// Gets the length of a file if it exists. /// Null if the file does not exist. /// </summary> /// <param name="this">Blob storage manager to use.</param> /// <param name="location">Location of the blob to get the length of.</param> /// <returns>Returns the length of the file if it exists, or null if it does not exist.</returns> public static long?GetFileLength(this IBlobStorageManager @this, BlobLocation location) { return(@this.GetFileLength(location.ContainerName, location.BlobName)); }
private static void FillFileLengths(IBlobStorageManager storage, PatientFilesGroupViewModel viewModel, int? dbUserId) { // reading file sizes from the storage // todo: use db to get file size (faster) foreach (var eachFile in viewModel.Files) { var fullStoragePath = string.Format("{0}\\{1}", eachFile.ContainerName, eachFile.BlobName); var mustStartWith = string.Format("patient-files-{0}\\", dbUserId); if (!fullStoragePath.StartsWith(mustStartWith)) continue; eachFile.FileLength = storage.GetFileLength(eachFile.ContainerName, eachFile.BlobName); } }