How does Joplin handle metadata for attachment files?

What exactly does Joplin do, if anything, with the metadata for attached files such as images and videos ( and I guess as well documents and text files or something, though maybe those are handled differently?).

I know, or at least I was informed, based on another post I made that when you attach an image or video to a note, it creates a copy of that within the local Joplin, and then points to it with the link in the note. You can do this with other notes too, for the same file, and it will remain in the database unless there are no notes pointing to it in which case it will be removed within 10 days (If necessary, please verify that this is right).

  • Does it strip the metadata?

  • Preserve all the original?

  • Add any of its own?

  • Does modifying the original file change the Joplin version at all (metadata or otherwise)? What about deleting it?

  • All filetypes treated the same?

I am not a dev just a user. This is how I understand how Joplin handles attachments / resources. If anyone knows better please feel free to correct me.

Please note that there are many types of “metadata” such as:

Embedded metadata - Extra information embedded within the file data itself such as EXIF camera data, Word data such as author, last printed date etc.
Filesystem metadata - Filename, modified / created / access dates, location of the actual file data on the storage media etc. This is stored in the filesystem and outside the actual file data.
Application metadata - Other information stored about a file by a specific application for its own purposes, so that application can manage that file. This would include programs such as Joplin and is also stored outside the actual file data.

Does it strip the metadata?

If you are referring to embedded metadata, like EXIF data, no. I have read a post where @laurent states that Joplin does not do anything to a file attached as a resource.

Preserve all the original?

Preserve “Original” embedded metadata within the copied file? Yes, as above.

Add any of its own?

Joplin does maintain its own application metadata for attached files but these are Joplin database records. It is not embedded into the file data of the Joplin copy itself. This application metadata appears to be information that allows Joplin to keep track of the file, what it is linked to and, if linked to nothing, whether it can be deleted after a set period of time. This is similar to filesystem metadata that exists outside of the file data itself.

Does modifying the original file change the Joplin version at all (metadata or otherwise)?

Not modifying the “original” file initially selected for attaching. When you attach a file to a Joplin note you are attaching a copy made in the Joplin resources folder (Joplin copy) and the note links to that. It is not making some kind of link between the note and the initially selected “original” file.

If you open the attached Joplin copy from within Joplin (i.e. there is a default handling application for that file type on the computer) it will watch the Joplin copy file and if the file changes it will update the Joplin copy. These changes to the Joplin copy will be synced to any other clients. This is a feature of the more recent versions of Joplin. Remember this is an update to the Joplin copy, not the “original” on your computer that you initially selected for attaching.

What about deleting it?

If you delete the “original” file you initially selected for attaching it will make no difference to the Joplin copy in the resources folder.

All filetypes treated the same?

As stated in the answer to your first question, yes. Of course for attached image files (that can be displayed) the attachment link is prefaced in markdown with a ! and this just instructs the renderer to display the image rather than just show a link.

1 Like

Thank you for the detailed response. Just a couple of follow-up questions if you don’t mind.

Joplin does maintain its own application metadata for attached files but these are Joplin database records. It is not embedded into the file data of the Joplin copy itself. This application metadata appears to be information that allows Joplin to keep track of the file, what it is linked to and, if linked to nothing, whether it can be deleted after a set period of time. This is similar to filesystem metadata that exists outside of the file data itself.

How does this affect file downloads from Joplin.

In other words, if I had uploaded an image, and then later I go into the note and “re-download”/copy, or share, the image directly from there, what kind of metadata will it have?

  • Will it simply be all the identical metadata that was on the original file when I first added it to the note?
  • Will include any metadata from Joplin? Something that identifies it came from the app / client?
  • Is this different at all across devices - desktop vs mobile?

Not modifying the “original” file initially selected for attaching. When you attach a file to a Joplin note you are attaching a copy made in the Joplin resources folder (Joplin copy) and the note links to that. It is not making some kind of link between the note and the initially selected “original” file

So slightly tangential to the original question, but is this done at some kind of elevated compression rate? Because I have noticed that when I add files to a Joplin note, the Joplin BB definitely does not increase by the total amount of all the original files I have added.

EDIT: For full clarity, I am talking about the Android app on this last one (is there any chance to mobile clients handle attachment copying differently, in order to save storage space?)

@dpoulton is correct, in general Joplin doesn’t change any metadata, not when attaching, not when syncing, downloading or uploading.

The only exception is when you attach an image and choose to resize it. In that case, the metadata most likely will be gone (the app won’t clear it but won’t try to preserve it either). Whether it’s kept or not is undefined basically. So if you want to always preserve the metadata, make sure you don’t resize the images when you attach them.

1 Like

It does not affect the files at all. You can test it yourself.

Select a test file and SHA1 hash it. Attach that file to a Joplin note. Then save the attached file from the Joplin note to the computer. Then SHA1 hash that downloaded file. You will find that the hashes for both the uploaded file and the downloaded file match. This shows that what came out of Joplin was exactly the same as what went into it.

If you are referring to the Joplin database, it will not get that much bigger as attachments are not stored in the database. Only Joplin metadata about the attached file is stored in the database and these record sizes are measured in bytes. The attachment itself is stored, unmodified, in a separate folder.

With regards to mobile this is why Joplin has several options on mobile for downloading attachments, namely, "Always", "Manual", "Auto". It allows you, when syncing with the server, to prevent Joplin from filling your mobile storage with attachments you do not need on your mobile device.

If you are referring to the Joplin database, it will not get that much bigger as attachments are not stored in the database. Only Joplin metadata about the attached file is stored in the database and these record sizes are measured in bytes. The attachment itself is stored, unmodified, in a separate folder.

Where would this be saved then? Even when I go into the apps manager and look at the total size of the Joplin installation on my device, it does not appear to be nearly large enough to contain everything I have attached to notes so far.

With regards to mobile this is why Joplin has several options on mobile for downloading attachments, namely, “Always”, “Manual”, “Auto”. It allows you, when syncing with the server, to prevent Joplin from filling your mobile storage with attachments you do not need on your mobile device.

Now I’m a little bit confused because on my device I have only set the sync target for the local file system - that is I have never run it through any external cloud storage or anything like that. So I assume that a full Joplin version copy of any attachments is being made on my device in addition to the original copy of the file there? Or is something else going on that is preventing the Joplin DB from getting larger? (The client is making a reference to the original file version on my device?)