Using an uploaded asset from a node script


#1

I’m building an app that allows users to upload a csv and then process it with a Node script. Because they also have to add some credentials, I’m instructing them to Remix my app so they can upload the file and edit their own .env. I was hoping they could simply drag and drop their csv into the project view, but from my understanding this uploads it to the assets “folder” which doesn’t actually live inside the project, but behind a separate CDN. This means the node script can’t simply load those files with fs.

What is the best way to work around this? I know I could probably create a page that lets users upload the file and use a server to save it to the app instead of assets, but I’d prefer to avoid that if possible.

Thanks!


#2

We don’t have a great solution for this at the moment - we plan to revisit how we handle assets soon.

In the meantime, one option is once uploaded to assets using wget from the console to import that file locally, however, that’s not a great option for inexperienced users.

Another option would be to have a blank CSV file in your template project, that your users then copy and paste the contents of their CSV file into after remixing. This might be easier to understand and they wouldn’t need to change the filename in the code to match their file.


#3

Yeah, the goal is to make this as accessible as possible for non-technical users so the console isn’t an option. Sort of similarly, I think most people don’t even realize a .csv is actually a text file they can open to edit, especially since by default it would open in Excel or Numbers instead of a text editor.

Maybe a compromise would be to let them upload it to assets and then instruct them to copy/paste the link into a text field on the page which fetches the file from the server side? Not as seamless as I’d like but easier than building a file uploader.


#4

@Gareth I was just writing instructions for the upload & copy+paste solution I mentioned above, and noticed that my csv file is uploading directly into the project root now instead of going into assets. Did something change? This is exactly the behavior I want but I’m not sure why it’s happening.

I took a little video of it: https://www.dropbox.com/s/luj3679uie9v3v3/tweet-upload.mov?dl=0


#5

Yes, that’s right - it was available quicker than I thought, but you can now upload some file types like csv, txt, js etc. to the local filesystem with drag and drop.


#6

:open_mouth:

Amazing! That was the last hurdle I needed to figure out in my app so this is very exciting. Thank you!