public IEnumerable <BlobFileInfo> GetBlobsByChallenge(string challengeId) { var blobs = _container.ListBlobs(blobListingDetails: BlobListingDetails.Metadata) .OfType <CloudBlob>() .Where(b => b.Metadata.ContainsKey("challengeId") && b.Metadata["challengeId"].Equals(challengeId)); var toReturn = new List <BlobFileInfo>(); foreach (var blob in blobs) { var fileInfo = new BlobFileInfo { FileName = blob.Name, TeamId = blob.Metadata["teamId"], ChallengeId = blob.Metadata["challengeId"], Uri = blob.Uri, }; toReturn.Add(fileInfo); } return(toReturn); }
public (string BlobId, bool Created) PostBlob(Stream blob, string fileName, string hash) { var id = Guid.NewGuid().ToString(); // TODO: check if we have previously stored this file via the hash // Add FileReference record containing the hash var mimeType = MimeTypeConverter.GetMimeType(fileName); var blobInfo = new BlobFileInfo(id, hash, fileName, mimeType, blob.Length, DateTime.UtcNow); var metaData = new ItemMetadata { BlobRef = id, Name = "FileReference", Value = JsonConvert.SerializeObject(blobInfo) }; _aggregateState.LocalAdd(metaData); _azureBlobStore.UploadFile(id, blob); return(id, true); }
public FileViewModel(BlobFileInfo file) { File = file; }