Back

Wrong mime type

  • 0
  • Self Hosted
MrT2010
12 Aug, 2024, 15:55

Hello, if I upload an image using the .NET SDK, the mimetype for my png images is set to "application/octet-stream" instead of "image/png".

This is my code

TypeScript
    ```public async Task<string> CreateFileAsync(string bucketId, string filename, string content, string mimeType)
    {
        using var stream = new MemoryStream(Encoding.UTF8.GetBytes(content));

        var inputFile = InputFile.FromStream(stream, filename.ToLower(), mimeType);
        var fileId = ID.Unique();
        inputFile.Path=filename.ToLower();
        try
        {
            var fileToWrite = await _storage.CreateFile(bucketId, fileId, inputFile, new List<string>());
            return fileToWrite.Id;
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error: {ex.Message}");
        }
        return "";
    }```

I added "inputFile.Path=filename.ToLower();" just in case but no difference. What could be the problem?

selfhosted Appwrite Version: 1.4.13 Appwrite Nuget: 0.7.1

TL;DR
Issue with image mime type when uploading in .NET SDK. The problem might be caused by the ".ToLower()" method. Try using a different approach.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more