Quote for PDF local-copy plugin

Hi everyone,

Is this the right place to ask for a custom plugin to be built?

Here’s what I need.

When a user posts a link to an image on an external web site our Discourse pulls a local copy of that image and stores it on our existing Amazon S3 bucket and edits the post accordingly.

I would like a plugin that exactly mimics this behaviour, but for PDFs.

For example, if someone posts a link to this remote PDF file:

https://dl.djicdn.com/downloads/DJI_Air_2S/DJI_Air_2S_Release_Notes_enI.pdf

I would like that PDF downloaded/uploaded/copied to our Amazon S3 and the post edited and the link replaced from the external PDF to the new copy of the document on our cloudfront CDN.

Again, exactly as Discourse core does for any images that are linked to externally.

I guess the first question might be, is this even feasible? :thinking:

2 Likes

I just checked the discourse behaviour when you add a pdf file. It simply adds a link to download it unless you’re using Inline pdf previews - theme - Discourse Meta

So is your usecase to have such pdf previews for pdf file links too?

The key thing to think about here is, if pdfs links are added too often, then your server storage may fill up quickly.

No :slight_smile:

1 Like

Could you explain the usecase to me?

Sorry @fzngagan was there something unclear in my first post that I could expand upon? :thinking:

1 Like

I understand you want to store local copies of the pdf file like the local copies of images are stored in discourse. Yes, I do think its feasible.

Just wanted to understand the purpose of that. The reason I ask, is because unlike images, the pdf files can’t be compressed before storing them on s3 so it might end up taking a lot of space.

The end result, whether the file is stored on your setup, or whether it is a link, is that people can click and download it.

Sorry, looking at this again, and perhaps I had misunderstood the original requirement

On one of my sites we used to regularly upload PDFs until it was deemed too risky for non-staff to upload potential copyright material, so I took it out of the legal upload types.

I’m not convinced any plugin is required here, just update these settings?

Legal uploads will in any case be sent to S3 if S3 is set up correctly?

@Rich are you over thinking this or am I missing something?

Sorry everyone, I may not have described my requirements very well :slight_smile:

Yes, but I want them pulled/copied from their remote location.

Our users can upload PDFs directly at the moment, that’s not an issue.

Let me give you a scenario :slight_smile:

I’m going to post this link https://upload.wikimedia.org/wikipedia/commons/thumb/5/55/Tux_Enhanced.svg/878px-Tux_Enhanced.svg.png here on thepavilion.

It’ll appear as an image, like this:

Now in a few minutes, a background task will kick in and Discourse will fetch a copy of that remote image and store it locally. Discourse will also edit this post automatically and replace the remote link with the new local image link and it’ll be something like https://thepavilion.io/uploads/whatever/878px-Tux_Enhanced.svg.png.

Magic :smiley:

Now lets say I am post a link to this remote PDF file: https://dl.djicdn.com/downloads/DJI_Air_2S/DJI_Air_2S_Release_Notes_enI.pdf

Here it is!

You can click on that and view it, because it will be downloaded from the remote location (djicdn.com)

But let’s say in six months time that link goes dead because the djicdn.com web site has deleted the PDF, or maybe updated the contents of it.

Now my post contains a dead link :cry:

What I would like to happen is exactly what happens when people post a link to a remote image.

Discourse goes and fetches a local copy of that image and serves it up.

So even if the remote image location gets removed or deleted this post will still contain a copy of the original.

2 Likes

You know I could swear this was core logic at one point but it might have just been annoying users uploading not linking. :sweat_smile:

2 Likes

I understand your idea now. I guessed it but wanted to confirm. :slight_smile:

I’ll send you a PM regarding the quote and timeline.

1 Like

@Rich
I’ve sent a PM regarding this. :slight_smile: