public async Task AddImageAsync(Stream stream, string originalName, string userName) { var imageProps = UploadUtilities.GetImageProperties(originalName, userName); var imageBlob = _imagesContainer.GetBlockBlobReference(imageProps.FileName); await imageBlob.UploadFromStreamAsync(stream); await UploadUtilities.RecordImageUploadedAsync(_dbContext, imageProps.UploadId, imageProps.FileName, imageBlob.Uri.ToString(), imageProps.UserHash); }
public async Task AddImageAsync(Stream stream, string originalName, string userName) { await InitializeResourcesAsync(); UploadUtilities.GetImageProperties(originalName, userName, out string uploadId, out string fileName, out string userId); var imageBlob = _uploadContainer.GetBlockBlobReference(fileName); await imageBlob.UploadFromStreamAsync(stream); await UploadUtilities.RecordImageUploadedAsync(_dbContext, uploadId, fileName, imageBlob.Uri.ToString(), userId); }
public async Task AddImageAsync(Stream stream, string originalName, string userName) { var imageProps = UploadUtilities.GetImageProperties(originalName, userName); var localPath = Path.Combine(ImageFolder, imageProps.FileName); var imageUri = $"{ImageFolderUri}/{imageProps.FileName}"; using (var fileStream = File.Create(localPath)) { stream.Seek(0, SeekOrigin.Begin); await stream.CopyToAsync(fileStream); } await UploadUtilities.RecordImageUploadedAsync(_dbContext, imageProps.UploadId, imageProps.FileName, imageUri, imageProps.UserHash); }
public async Task AddImageAsync(Stream stream, string originalName, string userName) { UploadUtilities.GetImageProperties(originalName, userName, out string uploadId, out string fileName, out string userId); string localPath = Path.Combine(ImageFolder, fileName); string imageUri = ImageFolderUri + "/" + fileName; using (var fileStream = File.Create(localPath)) { stream.Seek(0, SeekOrigin.Begin); await stream.CopyToAsync(fileStream); } await UploadUtilities.RecordImageUploadedAsync(_dbContext, uploadId, fileName, imageUri, userId); }
public async Task AddImageAsync(Stream stream, string originalName, string userName) { await InitializeResourcesAsync(); UploadUtilities.GetImageProperties(originalName, userName, out string uploadId, out string fileName, out string userId); var imageBlob = _uploadContainer.GetBlockBlobReference(fileName); await imageBlob.UploadFromStreamAsync(stream); //added code: get the URI from _publicContainer instead of _uploadContainer string imagePath = imageBlob.Uri.ToString().Replace("images", "images-watermarked"); //store the _publicContainer URI instead of upload container URI //await UploadUtilities.RecordImageUploadedAsync(_dbContext, uploadId, fileName, imageBlob.Uri.ToString(), userId); await UploadUtilities.RecordImageUploadedAsync(_dbContext, uploadId, fileName, imagePath, userId); }