Reading static file in function

Hey! I’m trying to use a function that sends down a PDF to authenticated users.

I’m having problems reading the static PDF file when my function is deployed. I even found this example: https://github.com/netlify/function-deploy-test/blob/master/lambda/zipped-function/zipped-function.js

I copied this example line for line (and file for file) and this guy https://github.com/netlify/function-deploy-test/blob/master/lambda/zipped-function/zipped-function.js#L10
still prints “undefined” in the logs.

Halp!

Hey @shayneo,
I’m not sure what’s missing in that example, but you may be able to try something like this:

The deployed function that sends down a pdf is here: https://examples.netlify.horse/.netlify/functions/send-down-pdf

The main difference is that your netlify.toml would probably be less complicated :slight_smile: If you want your function to have its own dependencies aside from the root package.json, you’d do something like this:

# netlify.toml
functions = "func"
command = "cd func/send-down-pdf/ && npm install"

Let us know if that helps or if you have other questions.

1 Like