giray
giray4w ago

Duplicate a File

I am trying to copying an Entity in the DB, which has a file associated to it to another user. So when a user tried to duplicate an entity, I need to: 1. Copy entity to the new user 2. If there is a file attached to it, duplicate it and attach to the new Entity created. I could not figure out how to duplicate an existing file in Convex. Any idea?
2 Replies
Convex Bot
Convex Bot4w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
erquhart
erquhart4w ago
There should be a less resource intensive way to do this, but the approach you'll need to take is: 1. Set up an http action to serve the existing file: https://docs.convex.dev/file-storage/serve-files#serving-files-from-http-actions 2. Use an action to fetch the file from the http action and store it, effectively duplicating it: https://docs.convex.dev/file-storage/store-files#storing-files-in-actions

Did you find this page helpful?