Skip to content

lukemcfarlane/multipart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Multipart

An AngularJS module that helps build a multipart HTTP request body consisting of binary and/or non-binary parts.

The resulting body can be returned either as an ArrayBuffer via req.getBuffer(), or as a string via req.toString().

Usage

  1. Include the following Javascript files:

    • multipart.js
    • stringview.js (StringView polyfill)
  2. Register 'multipart' as a requirement for your module:

    var myApp = angular.module('myApp', [ 'multipart' ]);
  3. Inject the 'MultipartRequest' & 'RequestPart' services:

    myApp.service('myService', function(MultipartRequest) }
        ...
    });
  4. Build a multipart request as follows:

    var req = new MultipartRequest('my_boundary');
    var part1 = new RequestPart();
    part1.addHeader('My-Header', 'some value');
    part1.addHeader('My-Other-Header', 'some other value');
    part1.setBody({ Title: "My Title" });
    req.addPart(part1);
    var part2 = new RequestPart();
    part2.addHeader('Content-Type', 'application/octet-stream');
    part2.setBody(<ARRAY_BUFFER>);
    req.addPart(part2);
    var buffer = req.getBuffer();

About

An AngularJS module that helps build a multipart HTTP request body consisting of binary and/or non-binary parts.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published