How to address a static asset for an email attachment?


#1

Hi, I have a logo.png in the public folder, but when I create a bundle it is moved to: bundle/programs/web.browser/app/logo.png

So I am worried that nodemailer attachment path to the static PNG:

path: `${process.env.PWD}/public/logo.png`,

Will be wrong come deployment. How do people get the path to their static resources?


#2

This shouldn’t be an issue because the asset will be served by the meteor app from {origin}/public even though it is bundled on the server in a different directory.


#3

But this logo is not being served by the httpd, it’s being found by absolute path by nodemailer. And the bundler moves it around. So I am very confused how to address it!


#4

In nodemailer you can have attachments specified via a url (use href instead of path).


#5

Oh… For some reason. I assumed you were using a URL instead of a content ID. My bad for not reading the part about nodemailer attachments.


#6

That sounds like I’m adding a layer of complexity just to be able to reference a static resource.

Especially since I have no idea what the canonical URL is supposed to be either for this resource.

Is it really that hard to figure out where a static resource lives in a Meteor bundle? Extraordinary.


#7

As far as I know assets in the public folder will always be stored in bundle > programs > web.browser


#8

If it has to be stored in /public then I would say you are going to face issues getting the bundled path since these files are meant to be served to the client through http. On the other hand if you store the image in the /private directory, you can use Meteor’s Assets api. I think specifically the Assets.absoluteFilePath() would be of use here.