Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Last active December 6, 2021 14:49
Show Gist options
  • Save wilmoore/d9eb62a244e6caae8d48008c1cdf463c to your computer and use it in GitHub Desktop.
Save wilmoore/d9eb62a244e6caae8d48008c1cdf463c to your computer and use it in GitHub Desktop.
Income Sources :: Web3 Audio Upload API with Node.js

Income Sources :: Web3 Audio Upload API with Node.js

⪼ Made with 💜 by realpolyglot.dev

Todo

Article

Summary

What is this article about and what will it show them how to do?

When a user interface requires the user be presented with a file upload dialog, I answer the following questions:

  • Should I prevent the default form processing and handle it manually?
  • GET or POST (POST is required for sending file uploads?)

We are going to gloss over CORS here because it's too big of a topic and would take us out of the flow of the discussion.

Generally, when designing an "API", the default expectation is that we are talking JSON. Across programming languages and API frameworks, there are conveniences for handling forms. By forms I don't mean checking that text values conform to a minimum length. That's a different problem. Our focus here is file uploads.

Goals

As a result of them reading this article, what will they be able to do? It’s important for the reader to know not just what they will be learning, but why they should learn it.

Dealing with form data can get unwieldy fast; not to mention adding multipart form data to the mix. This exercise is meant to provide some insight into a few tools, libraries, and practices that can bring a bit of well-deserved clarity to the process.

Outline

Please complete in as much detail as possible.

  • The Stack
  • Web3 Storage

The Stack

The backend stack is Node.js. Phil Sturgeon does a great job of enumerating how dealing with Content-Type: multipart/form-data is a non-trivial task. Fortunately, the formidable (GitHub) library eliminates the nuance and provides a simple API to accessing file upload data.

Web3 Storage

IPFS ...

mkdir web3-audio-upload-nodejs
cd web3-audio-upload-nodejs
npm init -y

References

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