Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow buffer in order to upload files (userbase-js-node) #262

Open
Fubinator opened this issue Jan 20, 2021 · 1 comment
Open

Allow buffer in order to upload files (userbase-js-node) #262

Fubinator opened this issue Jan 20, 2021 · 1 comment

Comments

@Fubinator
Copy link
Contributor

I'm playing around with userbase-node-js right now. So far it's running really well, good job! One thing I noticed is that the uploadFile function expects an object of the File class, which is not available in node as far as I know.

What would be great would be if you could use node's File System API directly, for example with fs.readFileSync. The problem with this is that fs.readFileSync returns a buffer. This buffer must first be converted to a compatible format. Is there a way to do this in node at all? If so, the following way of uploading a file would still be very convenient:

const file = fs.readFileSync("/path/to/file.txt");

await userbase.uploadFile({
  databaseName: "...",
  itemId: "...",
  file
});
@j-berman
Copy link
Collaborator

j-berman commented Jan 20, 2021

Yep! Definitely possible and sensible. Good call. Added to the backlog

(userbase-js-node polyfills the File class so it's available to you as a global in node too btw)

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

No branches or pull requests

2 participants