Server Action Not sequential (synchronious) with S3 Upload

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.

:face_with_monocle:
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.
:face_with_monocle:

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:

  1. I set a value for the file extension.
  2. I run an API to get a random number.
  3. I set a Value (“RandomNumber”) connected to that random number
  4. I set a Value that makes the filename a combination of the filename/sah256, timestamp, and rand number so the file name is unique
  5. I run the Sign Upload Url
  6. I set a Value called {{sign}} that comes from the uploader
  7. I insert the picture name into my database
  8. I set a Value of the ID of the picture in the DB
  9. I query the DB to get the info like filename and remote address of S3 Bucket
  10. I have a condition if/then…
  11. If the sign says, “YES I WORKED” then do this (why does this say yes when the upload didn’t finish?)
  12. Then I call the API to “Mindee” (the places that analyzes receipts)
  13. Then I Update the database with receipt information

image

Community Page
Last updated: