Is it possible to extract the asset modified date from a file uploaded to AEM Assets?

Avatar

Avatar

peter-g

Avatar

peter-g

peter-g

18-07-2019

Files on a computer have a last modified date in their metadata. When files are uploaded to AEM, some of that metadata is kept and put into nodes. The rest gets lost, from what it seems.

I need to modify a workflow to: extract the last modified date from the file (not the AEM last modified date), and store it in a node that does not change. How can I access this metadata value from a Workflow workItem? Is this even possible to do without writing a separate service that triggers on upload, before the file gets touched by any AEM workflows?

The "Metadata Processor" step in DAM Update Asset is likely accessing the full list of metadata from the file and selectively choosing what to keep. I need to access the same file metadata, which includes the file last modified date, and I need to store it in a node. The last modified date I'm referring to is the one that shows up if you right click -> Get Info on a file on OS X for example. Any advice on the best approach to this would be greatly appreciated.

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

910

Correct Answer

1.0K

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

910

Correct Answer

1.0K
Jörg_Hoh
Employee

22-07-2019

If you use File.lastModified() you are querying the filesystem, not the metadata inside the file itself. Thus it's not preserved inside the file, and also not available inside AEM.

Jörg

Answers (5)

Answers (5)

Avatar

Avatar

peter-g

Avatar

peter-g

peter-g

22-07-2019

Well, that would be creating a new file so I think it would update for other reasons. The Java File.lastModified method returns the same modified date that Right click -> Get Info returns on mac. Although I'm not sure if this is because its pulling it from the system somehow or off the file itself.

Avatar

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

910

Correct Answer

1.0K

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

910

Correct Answer

1.0K
Jörg_Hoh
Employee

22-07-2019

I doubt that a JPG contains the last modification date as metadate within itself.

You can test it: Just copy the file. If the last modification date is the same as with the original, it can be inside the file's metadate. But if the date changes the last modification date is a property of the filesystem.

Avatar

Avatar

peter-g

Avatar

peter-g

peter-g

19-07-2019

Yes that's correct, but the metadata is part of the image.jpg file and displayed by the file system, from my understanding.

Avatar

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

910

Correct Answer

1.0K

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

910

Correct Answer

1.0K
Jörg_Hoh
Employee

19-07-2019

Hi,

Let me try to rephrase your requirement:

* I have a file (image.jpg) on my local desktop, which has a last modification date of Jan 1st 2019 (according to Finder or Explorer)

* I upload this image.jpg to my AEM

* a workflow step reads this last modification (from somewhere) and stores it in a property on the asset.

Is this correct?

In this case this metadata "last modification" is a metadata of the filesystem of your local machine. And when I upload this through the browser to AEM, this metadata is not copied over.

(It's different if this metadata is part of the image.jpg file.)

Avatar

Avatar

Tuhin_Ghosh

Avatar

Tuhin_Ghosh

Tuhin_Ghosh

18-07-2019

The easiest way I see is to use the Java File API and make a file.lastModified() call.

But as you said it needs to be a different service and wont be available in the workItem.

Thanks

Tuhin