Our app recently switched to direct uploads to S3 via Rails Active Storage (introduced in Rails 5.2) For the most part, it's working alright, but we're noticing that an error gets thrown around 2% of the time.
We've seen the following so far:
Status 0 (predominantly with Safari/ Mobile Safari):
Error storing "File_1.jpeg". Status: 0
Status 403:
Error storing "File_1.jpeg". Status: 403
Error reading:
Error reading "File_1.jpeg".
I imagine the last error relates to the file itself being invalid or corrupt. However, we're unsure what could be resulting in the first two errors. Searching around, I notice posts mentioning CORS settings being incorrect. However, we've made some configuration changes before on S3, and I would also think that if it was a CORS issue, we'd see failure a lot more frequently. This is what our CORS setting is:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
<CORSRule>
<AllowedOrigin>https://app.ourapp.com</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<MaxAgeSeconds>3600</MaxAgeSeconds>
<AllowedHeader>Origin</AllowedHeader>
<AllowedHeader>Content-Type</AllowedHeader>
<AllowedHeader>Content-MD5</AllowedHeader>
<AllowedHeader>Content-Disposition</AllowedHeader>
</CORSRule>
</CORSConfiguration>
We noticed in one multi-upload, that a user was able to upload 12 files successfully to active storage, but 1 error-ed out with status 0. The file itself wasn't corrupt or anything.
Any clue what could be causing direct upload flakiness sometimes?