Skip to content

Conversation

HeinrichvonStein
Copy link

@HeinrichvonStein HeinrichvonStein commented Dec 10, 2024

This change introduces a new pdf attachment tutorial.

The tutorial can be viewed here


<Accordion title="Step 2: Create the `PdfAttachmentQueue` class">
The `PdfAttachmentQueue` class below updates the existing [PhotoAttachmentQueue](https://github.com/powersync-ja/powersync-js/blob/main/demos/react-native-supabase-todolist/library/powersync/PhotoAttachmentQueue.ts)
found in the demo app. The highlighted lines indicate which lines have been updated. For more information on attachments, see the [attachments package](https://github.com/powersync-ja/powersync-js/tree/main/packages/attachments).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of highlighted lines it very cool!

dbFilename: 'sqlite.db'
}
});
/**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, I think the spacing here is slightly off, possibly being the cause of the syntax highlighting not working correctly for this comment
Screenshot 2024-12-11 at 9 28 43 AM

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah block comments don't render correctly unfortunately, but that space is very annoying - will definitely fix.

@benitav
Copy link
Collaborator

benitav commented Dec 11, 2024

@HeinrichvonStein Overall looks great - made some minor suggestions. One more meta thing is that the "Attachments Storage" heading for this Tutorial group is now no longer that accurate anymore. This PDF tutorial is more about a different file type, rather than the storage part? So maybe rename it to "Attachments / Files" in line with the Use Case Examples title, and rename the AWS S3 tutorial to "AWS S3 Storage" or similar.

@HeinrichvonStein
Copy link
Author

@HeinrichvonStein Overall looks great - made some minor suggestions. One more meta thing is that the "Attachments Storage" heading for this Tutorial group is now no longer that accurate anymore. This PDF tutorial is more about a different file type, rather than the storage part? So maybe rename it to "Attachments / Files" in line with the Use Case Examples title, and rename the AWS S3 tutorial to "AWS S3 Storage" or similar.

@benitav Thank you for the feedback and quick review. Does "Attachments / Files" not relate to storage though?

@benitav
Copy link
Collaborator

benitav commented Dec 11, 2024

A part of Attachments / Files is storage related (esp the backend side of this), but there is client-side code and stuff as well that's not exactly storage related in my mind. That's more about how to reference these files, as an example. Another way of putting this is a user will more commonly think "I want to sync files", not "I want to store files".

@HeinrichvonStein HeinrichvonStein merged commit cb06e75 into docs Dec 11, 2024
1 check passed
@HeinrichvonStein HeinrichvonStein deleted the feat/pdf-attachment branch December 11, 2024 08:49
Comment on lines +278 to +282
The `saveAttachment` method in the `PdfAttachmentQueue` class expects a base64 encoded string. We can therefore use
[react-native-fs](https://www.npmjs.com/package/react-native-fs) to read the file and return the base64 encoded string which is passed to `saveAttachment`.
<Note>
If your use-case generates a pdf file, ensure that you return a base64 encoded string.
</Note>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be nice to use expo-file-system/next at some point - it can read and write files in binary directly, avoiding the need for converting to/from base64.

https://docs.expo.dev/versions/latest/sdk/filesystem-next/#bytes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants