https://discord.gg/botpress logo
iOS Safari file picker 'take photo or video' “imag...
# 🤝help
g
Description: When users tap the + icon in the native (mobile) iOS Safari file picker, chooses “Take Photo or Video,” and repeat, every shot is automatically named image.jpg. Because Botpress uses that filename as the S3 object key, each new upload with the same name overwrites the previous one - so only the last photo shows up in the bot’s file buffer (the thumbnails above the text area). On Android Chrome this doesn’t occur, since the browser generates unique names. Key Details: Symptom: Photos taken one after the other replace the last image in the file buffer, and the Botpress /​{botId}​/files API returns the same file.id (and URL) for each shot when using “Take Photo or Video.” Root Cause: Mobile iOS Safari’s camera picker hands back every capture as image.jpg; that exact string is sent as "key" in the JSON payload to: /​{botId}​/files
Copy code
{
  "key": "image.jpg",
  "size": 74538,
  "accessPolicies": [
    "public_content"
  ],
  "index": false,
  "tags": {
    "source": "integration",
    "integrationName": "webchat"
  },
  "expiresAt": "2025-06-23T12:09:05.601Z"
}
Impact: Users cannot add more than one camera shot per message; the second capture always overwrites the first. Workarounds Attempted: 1) Client-side buffering via DataTransfer and synthetic change events - didn’t fix it, because (i think) the collision happens server-side. 2) Renaming File.name in the DOM - didn’t work, as the API still received image.jpg. 3) Monkey-patching fetch/XHR to intercept and rewrite body.key before upload - didn’t work either, likely because Webchat issues its upload from within an iframe or ServiceWorker, so parent-page patches never see the real /files call. See attached screenshots showing two consecutive captures (from Take Photo or Video) both labeled image.jpg, resulting in identical S3 keys, identical file IDs and, overwriting the previous image in the buffer hope someone can help 🙂 Thanks! https://cdn.discordapp.com/attachments/1375814431413502002/1375814431933726740/IMG_0114.jpg?ex=68330e89&is=6831bd09&hm=7900ccda2b6034c53b0e6a4865898d04894b3e6d1b9ad54af422e80b2a3b5a33& https://cdn.discordapp.com/attachments/1375814431413502002/1375814432806146058/IMG_0115.jpg?ex=68330e8a&is=6831bd0a&hm=e2ac113e95da7694197f98c5a201ea4aef44a22ebd0cdb22f454b32ed58c5e61&
p
Are you using webchat? Would you mind providing reproduction steps?
g
I just saw this leanne thanks for your reply, so basically (you dont need anything fancy to replicate) deploy a bot to a page, make sure you have enable file upload on, then open that page on your iphone or ipad (this is an ios safari specific issue, this doesnt happen on android chrome) then click the file picker, select take photo or video, snap a picture and click use photo. without sending it to the bot, click the file picker again, take photo or video again, use photo again, then the photo you just took will overwrite/replace the first image you took in the buffer.
i am pretty sure that i identified the reason (its always called "image.jpg" and when botpress uploads this to the files api, it uses the exact same key and returns the exact same file id and url.
the key being "image.jpg"
i think an easy fix would be to pre-pend a timestamp (ms) to the default "image.jpg", before botpress makes the files api call so that its always unique. but i couldnt work out how to do it after 2 days of trying lol
p
Thank you for the feedback, I've let the team know of this issue.
g
youre a star, thanks again leanne!
p
No worries!