actually i dont really know the exact question, but hope this would help
if you want to send files to your own db you can use formData, it helps you to send it to server
about the attachment_id, i think you can use random string or simple counter to make your file has unique