Andrew
Andrew

Reputation: 2949

C# Base64 String file extension mime type

When I send a base64 string to an web api, do I need to pass the mime type e.g. jpg to define the file extension when the file is saved? if not how would I know what file type to save it as?

Upvotes: 0

Views: 1351

Answers (1)

Mark McWhirter
Mark McWhirter

Reputation: 1196

You could either send the file type in a separate variable, prepend it with a separator to the base64 string then extract it, or convert the base64 string to a byte array and then read the first few bytes to determine the image format.

Upvotes: 1

Related Questions