powersync.dart icon indicating copy to clipboard operation
powersync.dart copied to clipboard

Relax fileExtension requirement in attachmentQueue

Open n0mad-d3v opened this issue 8 months ago • 1 comments

Hello powersync team 👋

This PR fixes #268 and updates the watchIds method in the Attachments helper to make the fileExtension parameter optional. This enables support for storing files with different extensions in the same attachmentQueue, which is useful in cases where:

  • The extension is already part of the filename (e.g., managed directly in the storage bucket like Supabase).
  • The developer wants more flexibility in handling mixed file types under a unified queue.

Motivation: Currently, the API assumes a single extension per queue, which limits use cases that involve multiple file types. Making fileExtension optional opens up broader usage while maintaining backward compatibility.

⚠️ This includes a breaking change. And along that, I'm wondering if it shouldn't be pushed further to be able to specify a Map<String, String?> for <filename, extension?> in the whatchIds to allow even more flexibility and usecases.

This change was inspired by this Discord thread.

WDYT? Looking forward to feedback!

PS: There is also a change about ensuring directory creation. In my usecase, I'm using Teams' ids as subdirectory so it's fully dynamic and my filename is like the following: {teamId}/{attachmentType}/{attachmentId}.{attachmentExtension}.

n0mad-d3v avatar Apr 18 '25 04:04 n0mad-d3v

Hi @stevensJourney, thanks for the feedback! It's interesting to see that the question raised in other technos as well and that a common ground has been found to tackle this issue. Of course, I think consistency is key as Powersync users expect it when using the library from one stack to another.

I'll have a deeper look in your changes and try to adapt my PR asap 🤓

n0mad-d3v avatar Apr 24 '25 06:04 n0mad-d3v

Hey @simolus3, First of all, thanks a lot for the review 🙏

Regarding this PR, I'll do the changes anyway, mainly from a learning perspective 🤓 But no worries if it doesn't get merged or if the new version you're working on guys is better 🤗 I'm glad this is reworked on your side and really am impatient to test it! I'll update this as soon as I can and leave you the choice to merge or not 👍

n0mad-d3v avatar Aug 19 '25 05:08 n0mad-d3v

I think that you're progressing much faster than me on the #311 😅 Sorry, I had lot of work and didn't manage to progress on this one. I'll close it if that's fine for you 🤓

n0mad-d3v avatar Sep 18 '25 11:09 n0mad-d3v

Sure 👍 Also, thanks for pushing on this and taking the time to contribute! We'll do our best to release the other PR soon 🫡

simolus3 avatar Sep 18 '25 12:09 simolus3