paleobot / pbot-dev

Codebase and initial design documents for pbot client
MIT License
2 stars 2 forks source link

Allow an image to be attached to multiple specimens #214

Open doricon opened 10 months ago

doricon commented 10 months ago

Some images have multiple specimens in them, can we allow an image to have a relationship to multiple specimens so that users do not have to upload the image 2+ times?

NoisyFlowers commented 5 months ago

This is not a terrible idea. It would also help conserve image storage resources.

However, there are problems.

As currently implemented, there is one Image node per image and that node is linked to one Specimen node. The images themselves are stored in directories named for a specimen's pbotID. That directory path is used to form an html link to the image. For instance: https://pbot.paleobiodb.org/images/d833e8b4-2442-44fa-99e7-52e96b07b7e1/AF1404-C2_SJ46_AF1404-C2-036B.JPG

Since our form allows the user to enter either a file to upload or a link to an image, it is currently possible, in theory and practice, to reuse an uploaded image for more than one specimen. Each use would have a unique Image node.

There are two problems with this: 1) We don't make that url available to the user. 2) The image is stored in a specimen-specific directory

(1) is simply a missed beat. We could surface that url in the successful creation message. (2) is a bigger problem, at least conceptually. It seems wrong to reuse a url that is named for another specimen. We'd want to change image directory naming convention to something else. My first thought is the pbotID of the Image node, but that doesn't make sense if the whole point here is that an image can have multiple Image nodes. Maybe a random number, but then we'd have no record of db association outside of the db. That feels a little scary for some reason, but maybe it's ok. Not sure how best to handle this.