OK I misunderstood the api call, I needed:

 Util.downloadUrlToStorageInBackground(url*+fileName *



On Tuesday, February 27, 2018 at 3:22:25 PM UTC+8, Gareth Murfin wrote:
>
> I must be doing something wrong because even public pdfs dont work like 
> the one you use, but here my action listener never gets called (I also 
> assume id see the file on my pc at C:\Users\user\.cn1 if it worked?)
>
> my method:
>
>  try
>                 {
>                     downloadPDF("https://www.polyu.edu.hk/iaee/files/
> ","pdf-sample.pdf");//StateMachine.getBaseUrl(),file);
>                 }
>                 catch(Exception e)
>                 {
>                     _("Warning PDF failed to download ! "+e.getMessage());
>                     e.printStackTrace();
>                 }
>
>
>     private void downloadPDF(String url, String filename)
>     {
>         filename=StringUtil.replaceAll(filename, " ", "%20");           
>         _("downloadPDF from "+url+""+filename);
>         FileSystemStorage fs = FileSystemStorage.getInstance();
>         String fileName = fs.getAppHomePath() + filename;
>         if(!fs.exists(fileName)) {
>             _("file does not exist downloading it");
>             Util.downloadUrlToStorageInBackground(url, fileName, new 
> ActionListener(){
>                 @Override
>                 public void actionPerformed(ActionEvent evt) {
>                     _("download complete");
>                 }
>             });
>         }
>         else
>         {
>             _("we already have this pdf so bail.");
>         }
>         //Display.getInstance().execute(fileName);
>     }
>
> On Tuesday, February 27, 2018 at 3:08:02 PM UTC+8, Gareth Murfin wrote:
>>
>> I am trying to get a file like this
>>
>> FileSystemStorage fs = FileSystemStorage.getInstance();
>>         String fileName = fs.getAppHomePath() + filename;
>>         if(!fs.exists(fileName)) {
>>             Util.downloadUrlToFile(url, fileName, true);
>>         }
>>
>> But I just see the spinner going forever and it never arrives, no errors 
>> reported in catch. One problem is if I visit the link in my browser it 
>> needs me to login to get it, and the url is https, so I guess my question 
>> is can you use downloadUrlToFile in this way? All my other requests require 
>> me to add a token to the url too, do I just add this to the download url ?
>>
>> Is there any examples of downloading from https?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/20b341fa-540e-461c-931e-adc5e63ecd79%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to