Hey ya’ll,
I’m attempting to read a receipt from a store and put the info in a database. I’m doing an AWS S3 upload. It works great. I can upload no problem, and access the pictures later.
I’m also connecting with an API to read receipts. The API works great.
**However, when I put them together in one server action my results vary. **
Sometimes it works sometimes it doesn’t.
I discovered that if I upload a very small image file it works fine. If I upload a large image file the API for the receipt throws an error saying it cannot access the file, it’s not there.
In fact, if the API runs before the picture is uploaded the picture doesn’t finish uploading. If I turn off the API everything works fine. If I turn off the upload and assign the API to a file I know is on the server everything works fine.
That leads me to believe the server action is not running sequentially when an S3 upload is involved.
MORE DETAILS:
You can see the image here:
- I set a value for the file extension.
- I run an API to get a random number.
- I set a Value (“RandomNumber”) connected to that random number
- I set a Value that makes the filename a combination of the filename/sah256, timestamp, and rand number so the file name is unique
- I run the Sign Upload Url
- I set a Value called {{sign}} that comes from the uploader
- I insert the picture name into my database
- I set a Value of the ID of the picture in the DB
- I query the DB to get the info like filename and remote address of S3 Bucket
- I have a condition if/then…
- If the sign says, “YES I WORKED” then do this (why does this say yes when the upload didn’t finish?)
- Then I call the API to “Mindee” (the places that analyzes receipts)
- Then I Update the database with receipt information
Last updated: