Page 1 of 1

mp3 Download via tsnetgetSync

Posted: Thu Jun 25, 2020 4:34 pm
by MichaelS
Hello,
i am trying to download an audio file in mp3 quality with tsnetgetSync Command.
The Code is simple :

Code: Select all

on mouseUp  
   local tRequestHeaders, tResponseHeaders, tResult, tBytes, tData
   local tSettings, tCharNo, tUrl, tProxyUrl
   
   put field "sftp_url" into tUrl
   put field "sftp_username" into tSettings["username"]
   put field "sftp_password" into tSettings["password"]
   put empty into field "response"
   
   -- Disable connection re-use if required
   if the hilite of button "Reuse Connection" is false then
      put true into tSettings["no_reuse"]
   end if
   
   put tsNetGetSync(tUrl, tRequestHeaders, tResponseHeaders, tResult, tBytes, tSettings) into tData
   
   if tResult is not 0 then
      answer "Error" && tResult && "returned from server"
   end if
   
   put tData into URL ("file:/home/michael/test.mp3")
end mouseUp
The Download is working. The Original mp3 and the downloaded Version has the same size. But when i start the downloaded mp3 i hear the Music and strange digital Noises , the Quality of the tranmitted mp3 is poor.

Is there a better Way to download mp3 from my Server ? I want to do this with sftp. It should work with my Indy Licence.

Re: mp3 Download via tsnetgetSync

Posted: Thu Jun 25, 2020 5:20 pm
by bangkok
Perhaps you should try :

Code: Select all

   put tData into URL ("binfile:/home/michael/test.mp3")
(binfile = binary file)

I do not see how the tsNetGetSync command could "reduce" the quality of a downloaded file (mp3 or any other type of file).

Re: mp3 Download via tsnetgetSync

Posted: Thu Jun 25, 2020 6:20 pm
by MichaelS
Hi bangkok,
yes that was the Problem. With binfile it works.

Thank you for fast reply.
Michael