Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Download] Size of asset is not visible #819

Closed
bmalecki opened this issue Oct 29, 2019 · 4 comments
Closed

[Download] Size of asset is not visible #819

bmalecki opened this issue Oct 29, 2019 · 4 comments
Assignees
Labels
enhancement New feature, or improvement to an existing feature.
Milestone

Comments

@bmalecki
Copy link
Contributor

Feature Request

Is your feature request related to a problem? Please describe.
When an uploaded asset does not contain metadata dam:size (e.g. /content/dam/your-app/example-image.jpg/jcr:content/metadata), size of asset is not visible on Download component.

Describe the solution you'd like
To fix this issue we need to change DownloadImpl code in Core Components Repository (https://github.com/adobe/aem-core-wcm-components/blob/master/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/DownloadImpl.java#L209)

from

size = null;
Object rawFileSizeObject = downloadAsset.getMetadata(DamConstants.DAM_SIZE);
if (rawFileSizeObject != null) {
long rawFileSize = (Long) rawFileSizeObject;
size = FileUtils.byteCountToDisplaySize(rawFileSize);
}

to

long rawFileSize = downloadAsset.getOriginal().getSize();
size = FileUtils.byteCountToDisplaySize(rawFileSize);

Are there alternatives?
Another solution to resolve this issue is run "Add asset size" workflow over an asset. This workflow adds dam:size metadata to assets.

@msagolj msagolj added the enhancement New feature, or improvement to an existing feature. label Oct 30, 2019
@msagolj
Copy link
Contributor

msagolj commented Oct 30, 2019

@bmalecki thank for your change request. Your suggestion looks good to me. Not sure how much slower it is then just checking the DAM property, as its is trying to access the binary to get the size.

Maybe better to first try dam:size and if null , go for .getOriginal().getSize(). ? Would you be OK to post your solution as a PR to the development branch so it gets reviewed/merged ?

@joerghoh
Copy link
Contributor

We should be careful here, as unintentionally you might end up with loading the underlying asset from the datastore, just to determine its size. While in many cases (especially with a local datastore) this is not a problem, it can be very problematic when you work with a S3 datastore.

@msagolj msagolj added the good first issue Good starter issue for new contributors. label Oct 30, 2019
bmalecki added a commit to bmalecki/aem-core-wcm-components that referenced this issue Oct 31, 2019
bmalecki added a commit to bmalecki/aem-core-wcm-components that referenced this issue Oct 31, 2019
bmalecki added a commit to bmalecki/aem-core-wcm-components that referenced this issue Oct 31, 2019
@gabrielwalt gabrielwalt added this to the Next Release milestone Nov 7, 2019
@gabrielwalt gabrielwalt added in progress and removed good first issue Good starter issue for new contributors. in progress labels Nov 7, 2019
@vladbailescu vladbailescu self-assigned this Nov 7, 2019
vladbailescu pushed a commit that referenced this issue Nov 7, 2019
* Fix invisible size of Download component
* Add test for Download component

Co-Authored-By: Bartlomiej Malecki <bmalecki995@gmail.com>
@vladbailescu vladbailescu modified the milestones: Next Release, 2.8.0 Nov 7, 2019
@andreeadracea
Copy link
Contributor

The problem was solved.

richardhand pushed a commit that referenced this issue Dec 2, 2019
* Fix invisible size of Download component
* Add test for Download component

Co-Authored-By: Bartlomiej Malecki <bmalecki995@gmail.com>
@richardhand
Copy link
Contributor

The code for this issue is merged to master and will be available in the upcoming 2.8.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature, or improvement to an existing feature.
Projects
None yet
Development

No branches or pull requests

7 participants