mirror of
https://github.com/D4M13N-D3V/comissions-app-core-api.git
synced 2025-03-14 01:54:55 +00:00
fix mimetypes
This commit is contained in:
parent
acd022cf41
commit
2b3f49b5e9
@ -86,7 +86,8 @@ public class ArtistRequestsController: Controller
|
||||
if(reference==null)
|
||||
return NotFound();
|
||||
var content = await _storageService.DownloadImageAsync(reference.FileReference);
|
||||
return new FileStreamResult(content, "application/octet-stream");
|
||||
var mimeType = _storageService.GetMimeType(reference.FileReference);
|
||||
return new FileStreamResult(content, mimeType);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -142,7 +143,8 @@ public class ArtistRequestsController: Controller
|
||||
if(reference==null)
|
||||
return NotFound();
|
||||
var content = await _storageService.DownloadImageAsync(reference.FileReference);
|
||||
return new FileStreamResult(content, "application/octet-stream");
|
||||
var mimeType = _storageService.GetMimeType(reference.FileReference);
|
||||
return new FileStreamResult(content, mimeType);
|
||||
}
|
||||
|
||||
|
||||
|
@ -822,7 +822,8 @@ public class CustomerRequestsController : Controller
|
||||
if(reference==null)
|
||||
return NotFound();
|
||||
var content = await _storageService.DownloadImageAsync(reference.FileReference);
|
||||
return new FileStreamResult(content, "application/octet-stream");
|
||||
var mimeType = _storageService.GetMimeType(reference.FileReference);
|
||||
return new FileStreamResult(content, mimeType);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@ -911,7 +912,8 @@ public class CustomerRequestsController : Controller
|
||||
if(reference==null)
|
||||
return NotFound();
|
||||
var content = await _storageService.DownloadImageAsync(reference.FileReference);
|
||||
return new FileStreamResult(content, "application/octet-stream");
|
||||
var mimeType = _storageService.GetMimeType(reference.FileReference);
|
||||
return new FileStreamResult(content, mimeType);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -4,4 +4,6 @@ public interface IStorageService
|
||||
{
|
||||
public Task<string> UploadImageAsync(Stream fileStream, string fileName);
|
||||
public Task<Stream> DownloadImageAsync(string fileRefrence);
|
||||
public string GetMimeType(string fileReference);
|
||||
|
||||
}
|
@ -51,5 +51,10 @@ namespace comissions.app.api.Services.Storage
|
||||
var stream = await response.Content.ReadAsStreamAsync();
|
||||
return stream;
|
||||
}
|
||||
|
||||
public string GetMimeType(string fileReference)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -34,7 +34,23 @@ namespace comissions.app.api.Services.Storage
|
||||
|
||||
return fileReference;
|
||||
}
|
||||
public string GetMimeType(string fileReference)
|
||||
{
|
||||
var extension = Path.GetExtension(fileReference).ToLowerInvariant();
|
||||
|
||||
switch (extension)
|
||||
{
|
||||
case ".jpg":
|
||||
case ".jpeg":
|
||||
return "image/jpeg";
|
||||
case ".png":
|
||||
return "image/png";
|
||||
case ".gif":
|
||||
return "image/gif";
|
||||
default:
|
||||
throw new NotSupportedException($"File extension {extension} is not supported.");
|
||||
}
|
||||
}
|
||||
public async Task<Stream> DownloadImageAsync(string fileReference)
|
||||
{
|
||||
// Get the file path based on the provided file reference
|
||||
|
Loading…
x
Reference in New Issue
Block a user