Recent

Author Topic: Download with progressbar  (Read 1759 times)

lazzaro2023

  • New Member
  • *
  • Posts: 26
Download with progressbar
« on: February 07, 2023, 06:56:54 pm »
Hi everyone!!!
I have a problem.
Is it possible to implement a procedure that shows me a progress bar while I download a file from the internet?
Can someone help me?

Handoko

  • Hero Member
  • *****
  • Posts: 5153
  • My goal: build my own game engine using Lazarus
Re: Download with progressbar
« Reply #1 on: February 07, 2023, 07:23:01 pm »
Hello lazzaro2023,
Welcome to the forum.

In the link below, you can find "File download" demo in the Networking category:
https://wiki.freepascal.org/Portal:HowTo_Demos

dje

  • Full Member
  • ***
  • Posts: 134
Re: Download with progressbar
« Reply #2 on: February 07, 2023, 07:43:11 pm »
I posted a threaded progressbar downloader here:
https://forum.lazarus.freepascal.org/index.php/topic,60314.msg450770.html#msg450770
The actual downloading code is maybe ~150 lines. I couldn't think of a smaller way of writing one.
I've also attached a project to this post. It should get you started

lazzaro2023

  • New Member
  • *
  • Posts: 26
Re: Download with progressbar
« Reply #3 on: February 09, 2023, 10:19:25 am »
Thanks for the posts!!
I need to do the same thing for uploading files.
Can you help me?

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2061
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Download with progressbar
« Reply #4 on: February 09, 2023, 11:09:49 am »
Can you help me?
We can try.
I need to do the same thing for uploading files.
Upload to where?
Basics are the same, just easier since a download with a progressbar can be wrong when the source not tell the real size (for such my download switch to a marquee and still tells in how fast it is)
So have your progressbar updated after each chunk you uploaded.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

lazzaro2023

  • New Member
  • *
  • Posts: 26
Re: Download with progressbar
« Reply #5 on: February 09, 2023, 12:02:44 pm »
Upload to where?
Internet
Basics are the same, just easier since a download with a progressbar can be wrong when the source not tell the real size (for such my download switch to a marquee and still tells in how fast it is)
So have your progressbar updated after each chunk you uploaded.
You have an example?

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2061
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Download with progressbar
« Reply #6 on: February 09, 2023, 12:12:32 pm »
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2061
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Download with progressbar
« Reply #7 on: February 09, 2023, 12:16:19 pm »
Upload to where?
Internet
Since "Internet" is no protocol but for transfers you need a protocol your answer is just .....
So what I showed you in my last post is for the FTP (File Transfer Protocol)
If that is not what you need, be more specific.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

lazzaro2023

  • New Member
  • *
  • Posts: 26
Re: Download with progressbar
« Reply #8 on: February 09, 2023, 01:20:41 pm »
Since "Internet" is no protocol but for transfers you need a protocol your answer is just .....
So what I showed you in my last post is for the FTP (File Transfer Protocol)
If that is not what you need, be more specific.

I apologize!!!
The protocol is http.

balazsszekely

  • Guest
Re: Download with progressbar
« Reply #9 on: February 09, 2023, 01:23:17 pm »
Since "Internet" is no protocol but for transfers you need a protocol your answer is just .....
So what I showed you in my last post is for the FTP (File Transfer Protocol)
If that is not what you need, be more specific.

I apologize!!!
The protocol is http.
Here you go:
https://forum.lazarus.freepascal.org/index.php/topic,44795.0.html

lazzaro2023

  • New Member
  • *
  • Posts: 26
Re: Download with progressbar
« Reply #10 on: February 09, 2023, 05:15:48 pm »
Here you go:
https://forum.lazarus.freepascal.org/index.php/topic,44795.0.html
Ok!
Thanks!
But there is no possibility to monitor with a progressbar the upload of the file ...

balazsszekely

  • Guest
Re: Download with progressbar
« Reply #11 on: February 09, 2023, 05:56:31 pm »
Here you go:
https://forum.lazarus.freepascal.org/index.php/topic,44795.0.html
Ok!
Thanks!
But there is no possibility to monitor with a progressbar the upload of the file ...
Did you download the attachment from Reply #2? I see a big juicy progressbar on the main form.  ::)

lazzaro2023

  • New Member
  • *
  • Posts: 26
Re: Download with progressbar
« Reply #12 on: February 26, 2023, 03:22:56 pm »
Thank you for the report. I saw the progress bar in the foreground, but it indicates the bytes read from the read stream buffer, not the bytes actually uploaded to the server. Do you have a solution for this on the client-side program? :)

 

TinyPortal © 2005-2018