Skip to content

A library to create readable "multipart/form-data" streams. Can be used to submit forms and file uploads to other web applications.

Notifications You must be signed in to change notification settings

scalajs-io/form-data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Form-data API for Scala.js

form-data - A library to create readable "multipart/form-data" streams.

Description

A library to create readable "multipart/form-data" streams. Can be used to submit forms and file uploads to other web applications.

Build Requirements

Build/publish the SDK locally

 $ sbt clean publish-local

Running the tests

Before running the tests the first time, you must ensure the npm packages are installed:

$ npm install

Then you can run the tests:

$ sbt test

Examples

FormData accepts strings, buffers and readables
import io.scalajs.nodejs.buffer.Buffer
import io.scalajs.nodejs.fs.Fs
import io.scalajs.npm.formdata._
import scalajs.js

val form = FormData()
form.append("my_field", "my value")
form.append("my_buffer", new Buffer(10))
form.append("my_file", Fs.createReadStream("/foo/bar.jpg"))
FormData accepts Http-response streams
import io.scalajs.nodejs.buffer.Buffer
import io.scalajs.nodejs.http.{Http, ServerResponse}
import io.scalajs.npm.formdata._
import scalajs.js

val form = FormData()
Http.request("http:https://nodejs.org/images/logo.png", (response: ServerResponse) => {
    form.append("my_field", "my value")
    form.append("my_buffer", new Buffer(10))
    form.append("my_logo", response)
})
FormData accepts Request streams
import io.scalajs.nodejs.buffer.Buffer
import io.scalajs.nodejs.http.{Http, ServerResponse}
import io.scalajs.npm.formdata._
import io.scalajs.npm.request.Request
import scalajs.js

val form = FormData()
form.append("my_field", "my value")
form.append("my_buffer", new Buffer(10))
form.append("my_logo", Request("http:https://nodejs.org/images/logo.png"))

Artifacts and Resolvers

To add the Form-data binding to your project, add the following to your build.sbt:

libraryDependencies += "io.scalajs.npm" %%% "form-data" % "0.5.0"

Optionally, you may add the Sonatype Repository resolver:

resolvers += Resolver.sonatypeRepo("releases") 

About

A library to create readable "multipart/form-data" streams. Can be used to submit forms and file uploads to other web applications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages