My ASP.NET Core API generates a SAS
for a file to be uploaded to Azure Blob Storage. Looks like the string is being wrapped in double quotes and this is creating a problem with the front end solution I'm using to upload files.
How can I return a string but make sure that it's not wrapped in double quotes?
This is the API controller:
public async Task<IActionResult> GetSAS(string blobUri, string _method)
{
if (string.IsNullOrEmpty(blobUri) || string.IsNullOrEmpty(_method))
return new StatusCodeResult(400);
// Get SAS
var sas = _fileServices.GetSAS(blobUri, _method);
return Ok(sas);
}
As discussed in the comments you have a [Produces]
attribute on the class that is forcing a JSON response. From the docs on ProducesAttribute
we can see it can be applied to an action as well as the controller. So, you can override for a particular action by adding it there, in your case you need text/plain:
[Produces("text/plain")]
public async Task<IActionResult> GetSAS(string blobUri, string _method)
{
//snip
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With