HELP regarding download component

is it possible to get file size and file name in a label when user click any download link.
and later on can be downloaded using download component?
i wasted my whole day doing this but failed.
i just wanted to return name and and size of the file from a direct link.

I will add some new things on the component for next release.

1 Like

Thanks @Mika
But is there any solution or Workaround to get file size and name from direct link now ?

Maybe if you write your own extension.
I dont know if there is current a existing extension for that.

yeah,
Finally i made it work using google scripts and java scripts.
by reading the current page title using clock when the url matches my google script.
but still its not getting filesize (context length).
btw,
thank you again for your your reply.

I add current new things to the “Download” event.
Now it returns too the downloaded:

  • file name
  • file path (useful to use your downloads then in your apps)

under testing:

  • file Size
1 Like

@Mika
thanks a lot brother.
you are cool :grinning::grinning::grinning::star_struck:

Do you need the file size before or after download?

Btw… I have testet now the file Size too… it works perfect.

It looks then like this:
1

The file Size is returned in bytes.

1 Like

I need filesize and the file name before download.
just like in any download manager.

Okay.
Then I know now what I have to add too :smile:

1 Like

yeah you have a very good programming skill. :slightly_smiling_face::relaxed:

1 Like

I learn every day more with new challenges :smile:

1 Like

bro , I just messaged you a link that might help you improving download component for all makeroid users.

I have added now following things.
I think this is what you want:

new

You can use this to get the size of a file that is online stored.
Too you can use it to check a size of a local stored file.

3 Likes

@Mika
Yeah Exactly… :heart_eyes::smile::grinning:

1 Like

this is what i had to write in order to get filesize using google app script.

function getfilesize(url) {
          var msg = '';
          var response;
     try {
            response = UrlFetchApp.fetch(url, {
          method: 'GET',
          headers: {'X-HTTP-Method-Override': 'HEAD'},
              followRedirects: true } // Default is true anyway.
        );
          }catch(e) {
            return e.toString();
          }
        var content_length = 0;
          if (response.getResponseCode() === 200) {
        var headers = response.getHeaders();
             content_length = NaN;
          
   for (var key in headers) {
                if (key.toLowerCase() == 'Content-Length'.toLowerCase()) {
                  content_length = parseInt(headers[key], 10);
                  break;
            }
     }
          }
        return content_length;
        }

**but from the next update It would be easier. thanks @Mika **

1 Like