storage
storage copied to clipboard
Content-type(media type) inference of Azure blob storage?
Now the blob storage client upload files with content-type application/octet-stream
.
Azure Storage Explorer supports determining content-type while uploading, how about implement this?
Hi. Do you mean by file extension or explicitly specifying?
By file extension.
Just a reminder :) @aloneguid
If this cannot be done via the file extension, would it be possible to allow it to be either specified when writing, or even by updating the properties?
blob.Properties["ContentType"] = "image/png";
await _blobStorage.SetBlobAsync(blob);
Sorry busy times. I'm not sure that setting properties on blob will work when saving it, I need to check how that works across implementations - we don't want it to be Azure only. It might be worth adding a property to Blob class itself, like Size one. Let me come back to you on that. Are you happy to contribute code?
I also have cross platform content type detection code which I can add to this library, it's already tested.
Hi Ivan, I am happy to contribute where I can. If you point me in the right direction I will make some time.
@aloneguid Is this still in the work ? The current implementation still uploads files with content type being "application/octet-stream". I would also be interested in the cross-platform content type detection ! :)
Sorry forgot about it ) I took mime type database from Linux, it's easily parseable. I can forward it to you if you want to take on the PR?
@aloneguid I would love to contribute to the project down the line. At the moment, I simply define the content-type within my controller, which isn't that pretty, but works (when I get back the files).
var contentTypeProvider = new FileExtensionContentTypeProvider();
if (!contentTypeProvider.TryGetContentType(fileDto.FileName, out String contentType))
{
contentType = "application/octet-stream"; // fallback
}
However, if you want to share the mime database you have and let me know where you would see this implementation within the project, I might have time during holidays to look at it.