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

Assets - Allow local upload #136

Merged
merged 23 commits into from
Jul 16, 2022
Merged

Assets - Allow local upload #136

merged 23 commits into from
Jul 16, 2022

Conversation

SaraVieira
Copy link
Contributor

@SaraVieira SaraVieira commented Jul 12, 2022

Adds support for local uploads

Related to #37

@vercel
Copy link

vercel bot commented Jul 12, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
webstudio-designer ✅ Ready (Inspect) Visit Preview Jul 16, 2022 at 4:11PM (UTC)

…-is/webstudio-designer into upload-assets-pt1
@SaraVieira SaraVieira mentioned this pull request Jul 15, 2022
7 tasks
@SaraVieira SaraVieira changed the title Start work for uploading assets sidebar Assets - Allow local upload Jul 15, 2022
Copy link
Member

@kof kof left a comment

Choose a reason for hiding this comment

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

almost there


# relative to the public directory
FILE_UPLOAD_PATH="uploads"
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 allow upload anywhere? without contraining to public directory? idk

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, it won't work outside of public

Copy link
Member

Choose a reason for hiding this comment

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

enforced by remix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yap

type ImageUpload = z.infer<typeof ImageUpload>;

export const action: ActionFunction = async ({ request, params }) => {
const uploads = path.join(__dirname, "../public");
Copy link
Member

Choose a reason for hiding this comment

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

we shouldn't use __dirname (logic where to upload shouldn't depend on where this code is, if we mode code it breaks), also I think this is still the wrong path to public

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not, it works

But what should I use?

Copy link
Member

Choose a reason for hiding this comment

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

is there anything in env that we can use? kinda need to have a stable reference to a root somewhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Messaed this on discord bt this dirname is the build and thats stable

const data = {
type: imageInfo.type,
name: imageInfo.name,
path: `/${path.join(folderInPublic, imageInfo.name)}`,
Copy link
Member

Choose a reason for hiding this comment

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

why do you wanna put path into database? we can always have a path based on the file name

Copy link
Member

Choose a reason for hiding this comment

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

is imageInfo.name having a unique part in it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is unique but that's mostly because then to show it in the frontend you don't have to check if the user is using S3 or wtv you can just have the path as src

Copy link
Member

Choose a reason for hiding this comment

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

In the frontend you want to show the image name, not the path, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

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.

None yet

2 participants