-1

I wrote a program in Java and deployed it to AWS Lambda by creating a JAR file containing all the necessary files. My request handler calls a method that tries to create 4 new FileInputStreams, with .bin files as inputs, in a try-catch. For example: InputStream stream = new FileInputStream("random.bin"). However, it's going to the catch statement after trying to create the first one due to an IOException. I have my class files in src/main/java/package. I had the .bin files in the directory that contains the src folder, and I also tried putting them all in one folder, but that didn't resolve the problem. Very confused how to resolve this problem. It's also not working when I call to read in a text file, so it's not just limited to binaries. I was thinking of putting the binaries in my S3 bucket and somehow reading them from there, but I haven't found anything much online detailing how to do that in Java.

Thanks!

Sukhpreet Pabla
  • 29
  • 1
  • 2
  • 6

2 Answers2

0

Your jar puts files in different locations then what your expect. This question might offer so insight on how to correctly access files in the jar.

Banjo Obayomi
  • 1,636
  • 15
  • 17
-1

AWS Lambda only allow write access in the /tmp folder of your function's filesystem. Try changing your code to match this path and try again.

GreatDharmatma
  • 627
  • 5
  • 12