Hi all, I have a question about sst. I'm building...
# help
c
Hi all, I have a question about sst. I'm building a simple new web app with NodeJS, and want to put a BINARY file into the lambda function. If I put the binary file into the
src
folder simply, it will be missing in the final lambda folder. Every know how to solve this problem??
m
You can try to require the file as a dependency. Just like we do with assets in react or react native.
const file = require('YOUR_FILE_PATH');
f
@Charles Zhang, let me know if the above solution works for you.
m
Hey @Charles Zhang, I tested with the text file, but it should work for a binary file as well.
f
Thanks @Mr.9715! @Charles Zhang you can also try using the
bundle.copyFiles
props:
Copy code
new sst.Function(this, "MyLambda", {
  bundle: {
    copyFiles: [{ from: "path/to/binary/file", to: "." }],
  },
  handler: "src/lambda.main",
});
This will copy the binary
file
to the Lambda package.
c
@Frank @Mr.9715 Thank you! I tried
bundle.copyFiles
and it works great. But the folder path is different between local and lambda environments, and the static file cannot be copied in LOCAL mode, so I use
IS_LOCAL
parameter to identify what path should I use.
f
I see. Can you share your folder structure?