Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

divshot-upload

Package Overview
Dependencies
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

divshot-upload

Upload app files to Divshot

  • 0.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
31
increased by181.82%
Maintainers
3
Weekly downloads
 
Created
Source

divshot-upload

Upload app files to Divshot

  • Install
  • Usage
  • API
  • Run Tests

Install

Server and Browserify

npm install divshot-upload --save

Browser/Angular

bower install divshot-upload --save

Usage

Server or Browserify

var fs = require('fs');
var upload = require('divshot-upload');
var fileStream = fs.creatReadStream('some-file.tar');
var uploadOptions = {
  token: 'user-token',
  environment: 'production',
  type: 'tar',
  config: {
    name: 'uploadapp',
    root: './'
  },
  files: {}
};

fileStream
  .pipe(upload(uploadOptions))
  .on('message', function (msg) {})
  .on('released', function (filepath) {})
  .on('releasing', function () {})
  .on('pushed', function () {})
  .on('unreleased', function (unreleasedFiles) {})
  .on('error', function (err) {});

Angular

<script src="/bower_components/divshot-upload/dist/upload.directive.js"></script>
Inject into app
angular.modules('myApp', ['divshot.upload']);
Use as directive

HTML

The <ds-upload/> element becomes a drag and drop zone OR you can click on it to upload a file

<div ng-controller="AppController">
  <ds-upload class="divshot-upload"
    ds-config="appConfig"
    ds-environment="environment"
    ds-token="token"
    ds-enter="onEnter()"
    ds-leave="onLeave()"
    ds-drop="onDrop()"
    ds-progress="onProgress(type, message)"
    ds-done="onDone()"
    ds-start="onStart()"
    ds-unreleased="onUnreleased(files)"
    ds-error="onError(message)"
    ds-host="host">
    
    Drop Here or Click Here to Upload File
    
  </ds-upload>
</div>

Controller

angular.modules('myApp')
  .controller('AppController', function ($scope) {
    $scope.environment = 'production';
    $scope.token = 'some-user-token';
    $scope.host = 'http://dev.host'; // OPTIONAL
    $scope.appConfig = {
      name: 'uploadapp',
      clean_urls: true
    };
    
    $scope.onEnter = function () {
      console.log('enter');
    };
    $scope.onLeave = function () {
      console.log('leave');
    };
    $scope.onDrop = function () {
      console.log('drop');
    };
    $scope.onProgress = function (type, message) {
      console.log(type + ':', message);
    };
    $scope.onDone = function () {
      console.log('Application deployed!');
    };
    $scope.onStart = function () {
      console.log('Upload started');
    };
    $scope.onUnreleased = function (files) {
      console.error('Not all files released.');
      
      Object.keys(files).forEach(function (filename) {
        console.error(filename + ' unreleased');
      });
    };
    $scope.onError = function (message) {
      console.error('ERROR:', message);
    };
  });

API

upload(options)

  • options
    • token - user authentication token
    • environment - environment to push to
    • type - type of file to upload (tar or zip only for now)
    • config - application configuration (taken from the divshot.json file)
    • host - OPTIONAL - the divshot api endpoint (Used for dev, test, and production environments). Defaults to production api.
    • files - OPTIONAL. an object of files where the key of each item is the relative path to the file and the value is an empty object. This is used to track unreleased files.

Events

The upload stream emits the following events

  • message - generic message from upload stream
    • callback should look like function (message) {}
  • releasing - started the releasing stage of the push
    • callbacked should look like function () {}
  • released - individual file has been released
    • callbacked should look like function (file) {}
  • pushed - build has been fully pushed and deployed
    • callbacked should look like function () {}
  • unreleased - only fired if there were unreleased files
    • calback should look like function (unreleasedFiles) {}
  • error - an error occured in the process
    • callbacked should look like function (err) {}

Run Tests

Runs server side tests and browser tests. Browser tests require that Phantomjs is installed

npm install
npm test

FAQs

Package last updated on 17 Jun 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc