multipart

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

Added by: Sam Deering

GitHub

Repository

lukemcfarlane/multipart

Stats

Stars: 0

Watchers: 0

Forks: 0

Module Description

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();
    

Module stats last updated: 2015-04-19 12:38:22

Disclaimer: Some data on this page may have been gathered from the authors GitHub respository. If you see any mistakes or outdated information please let us know. Thanks!