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

Add Next.js docs #5502

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add Next.js docs #5502

wants to merge 2 commits into from

Conversation

Murderlon
Copy link
Member

Closes #1958

@Murderlon Murderlon self-assigned this Nov 7, 2024
Copy link
Contributor

github-actions bot commented Nov 7, 2024

Diff output files
No diff

@Murderlon Murderlon requested a review from kvz November 7, 2024 13:58
Copy link
Member

@kvz kvz left a comment

Choose a reason for hiding this comment

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

Very nice work Merlijn! Left a few nits/Qs

can be a security risk**. Signature Authentication is a security measure that
can prevent outsiders from tampering with your Assembly Instructions.

Generating a signature should be done on the server to avoid leaking secrets.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Generating a signature should be done on the server to avoid leaking secrets.
Generating a signature should be done on the server to avoid leaking secrets. The signature itself can then be freely passed around as proof that whoever generated it, had the secrets only known to Transloadit and you as a customer. It is only valid for the instructions and time duration that the signature was generated for.


Before continuing you should have a [Transloadit](https://transloadit.com)
account and a
[template](https://transloadit.com/docs/getting-started/my-first-app/) setup.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
[template](https://transloadit.com/docs/getting-started/my-first-app/) setup.
[Template](https://transloadit.com/docs/getting-started/my-first-app/) setup.

<Tabs>
<TabItem value="app" label="App Router" default>

```ts
Copy link
Member

Choose a reason for hiding this comment

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

Should we mention somewhere what filepath we intend to save this in?

Copy link
Member

Choose a reason for hiding this comment

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

Should this have "use server"?

import '@uppy/dashboard/dist/style.min.css';

function createUppy() {
return new Uppy().use(Tus, { endpoint: '/api/upload' });
Copy link
Member

Choose a reason for hiding this comment

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

Looks like we're using tabs for indentation, if we switch to tabs it should be across the board i think, not just this doc.

},
template_id: templateId,
fields: {
// You can use this in your template.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// You can use this in your template.
// This becomes available in your Template as `${fields.userId}` and could be used to have a storage directory per user for example

// your other params like notify_url, etc.
});

const signatureBytes = crypto
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const signatureBytes = crypto
// Typically, here you would deny generating a signature for improper use (user not logged in, user tried to save data under unowned path, etc.
const signatureBytes = crypto

// your other params like notify_url, etc.
});

const signatureBytes = crypto
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const signatureBytes = crypto
// Typically, here you would deny generating a signature for improper use (user not logged in, user tried to save data under unowned path, etc.
const signatureBytes = crypto

// You can send meta data along for use in your template.
// https://transloadit.com/docs/topics/assembly-instructions/#form-fields-in-instructions
const { meta } = uppy.getState();
const body = JSON.stringify({ userId: meta.userId });
Copy link
Member

Choose a reason for hiding this comment

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

I think userId is not an ideal example from a security perspective. It's better to get the userId from the session on the server side than a post payload for tampering reasons. How about... the example becomes about avatar uploading, and a post field we accept is autoCropFace or sth?


:::warning

The server-side examples are simplified for demostration purposes and assume a
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The server-side examples are simplified for demostration purposes and assume a
The server-side examples are simplified for demonstration purposes and assume a


# Next.js

Integration guide for the [React][] components for the Uppy UI plugins and
Copy link
Member

Choose a reason for hiding this comment

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

Should this intro say something about Next?

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.

NextJS example
2 participants