Unable to download audio file using mediUri

Hello Team, I am using JavaScript SDK and using getArchitectPromptResource web API to get prompt details. In the API response, I am getting mediaUri and able to play it but not able to download it.

using below logic to download audio file

var element = document.createElement('a');
    var file = new Blob([mediaUri ], { type: 'audio/x-wav' }); // will accept any audio file
    element.href = URL.createObjectURL(file);
    element.download = 'audio.wav'; // file name
    element.click();

Have you tried just doing a simple HTTP GET using the mediaUri and then saving the response to the file system? That will download the file.

Hi @Ambuj_Dubey
Can you try to download using the Uri in Browser if it is working in browser then
you need to enable Response DeCompression using gzip, deflate and brotli.
Reference example from .NET Code AutomaticDecompression is the line which fixed my issue.

 HttpClientHandler clientHandler = new HttpClientHandler()
 {
     AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
     ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; }
 };
 HttpClient client = new HttpClient(clientHandler)
 {
     Timeout = _timeout
 };

Hi @Dileep_kaRanki I am not able download using the Uri in Browser.

@Ambuj_Dubey Could you post the error screenshots.

Hello @Dileepkaranki it's working now. Can we increase expiry time for mediaUri?

1 Like

I don't have information regarding it. @crespino could you answer his query

Hello,

No, the expiry time can't be modified through the API.

Regards,

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.