Hi All,
I have created one download component in which i want to show the file size along with download description. I am able to get the file size when i am doing drag and drop the file(pdf) from DAM by using asset.getOriginal().getsize(). But i am unable to get the size of file which I am browsing from my local machine. Is there any way to get the size of browse file as well ?.
Thanks in advance.
Solved! Go to Solution.
I think you want to get file size as metadata that you want to upload from your local file system, just to display to user that current file size it xxxx.
You can leverage plain html5 feature. Just create a listener on for <input type="file" id="files-upload">
var filesUpload = document.getElementById("files-upload");
filesUpload.addEventListener("change", function() {
alert(this.file.size);
}
Still i am not fully aware of your use case. Let me know if you are trying to achieve some thing else.
TO do this - you would need to write a custom HTL component that also has a Java backend. You can create a POJO that holds DAM Asset attributes and the file size being one of them. Then you would use Java logic to get the file size and use HTL to render all of the attributes including the file size
What do you mean with "browse file"? Do you want to get the size of the HTML file during the process of rendering the file? Or the size of other HTML files you are linking to?
Jörg
I think you want to get file size as metadata that you want to upload from your local file system, just to display to user that current file size it xxxx.
You can leverage plain html5 feature. Just create a listener on for <input type="file" id="files-upload">
var filesUpload = document.getElementById("files-upload");
filesUpload.addEventListener("change", function() {
alert(this.file.size);
}
Still i am not fully aware of your use case. Let me know if you are trying to achieve some thing else.
Adding Demo for What Ankur shared:- JS Bin - Collaborative JavaScript Debugging
Note:- Only need to check is the browser support.
~kautuk
Views
Likes
Replies