Coder Social home page Coder Social logo

angular2-file-drop's Introduction

angular2-file-drop

Angular2 component with Drag and Drop support for files

Install

npm install angular2-file-drop

Usage

import { Component, Output } from '@angular/core';
import { FileDropDirective } from 'angular2-file-drop';

@Component({
  selector: 'upload',
  template: `
    <div fileDrop
      [ngClass]="{'file-is-over': fileIsOver}"
      [options]="options"
      (fileOver)="fileOver($event)"
      (onFileDrop)="onFileDrop($event)">
      Drop file here
    </div>
  `,
  directives: [ FileDropDirective ]
})
export class PartiesUpload {
  public fileIsOver: boolean = false;
  @Output() public options = {
    readAs: 'ArrayBuffer'
  };

  private file: File;

  public fileOver(fileIsOver: boolean): void {
    this.fileIsOver = fileIsOver;
  }

  public onFileDrop(file: File): void {
    console.log('Got file!');
  }
}

Options

  • readAs? : DataURL, ArrayBuffer, BinaryString or Text

angular2-file-drop's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

angular2-file-drop's Issues

Issue uploading with safari

Thanks for the great script. It is working great for me on Chrome and saves a lot of work.
I am just having a problem with safari.

I have followed the tutorial here, but receive the below error when I try and load my app through safari.

Have you come across this?
thanks again

[Error] ReferenceError: Can't find variable: DragEvent
    (anonymous function) (modules.js:115280)
    (anonymous function) (modules.js:115304)
    fileEvaluate (modules-runtime.js:180)
    require (modules-runtime.js:109)
    (anonymous function) (modules.js:115146)
    fileEvaluate (modules-runtime.js:180)
    require (modules-runtime.js:109)
    (anonymous function) (app.js:310)
    fileEvaluate (modules-runtime.js:180)
    require (modules-runtime.js:109)
    (anonymous function) (app.js:411)
    fileEvaluate (modules-runtime.js:180)
    require (modules-runtime.js:109)
    (anonymous function) (app.js:1193)
    fileEvaluate (modules-runtime.js:180)
    require (modules-runtime.js:109)
    global code (app.js:1412)

Cannot find name 'FileAPI'

Although the app is functioning fine, getting this:

node_modules/angular2-file-drop/src/file-drop.ts (81, 7): Cannot find name 'FileAPI'.

Running meteor 1.6.0.1.

readme has a typo

There's ;-character where should be :-character in Output property:

@Output() public options = {
    readAs; 'ArrayBuffer'
  };

Should be

@Output() public options = {
    readAs: 'ArrayBuffer'
  };

Issue with angular-cli --aot option

When trying to build with --aot enabled (ng build --prod --aot) I get the following error:

0% compilingUnexpected value 'FileDropModule' imported by the module 'EntitiesModule'
Error: Unexpected value 'FileDropModule' imported by the module 'EntitiesModule'
    at /Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/@angular/compiler/bundles/compiler.umd.js:14326:37
    at Array.forEach (native)
    at CompileMetadataResolver.getNgModuleMetadata (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/@angular/compiler/bundles/compiler.umd.js:14311:46)
    at /Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/@angular/compiler/bundles/compiler.umd.js:13284:43
    at Array.forEach (native)
    at _extractModulesAndPipesOrDirectives (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/@angular/compiler/bundles/compiler.umd.js:13283:28)
    at analyzeNgModules (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/@angular/compiler/bundles/compiler.umd.js:13039:16)
    at OfflineCompiler.compileModules (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/@angular/compiler/bundles/compiler.umd.js:13115:20)
    at CodeGenerator.codegen (/Users/iminar/Dev/angular/modules/@angular/compiler-cli/src/codegen.ts:71:26)
    at AotPlugin._make (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/@ngtools/webpack/src/plugin.js:186:43)
    at Compiler.<anonymous> (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/@ngtools/webpack/src/plugin.js:151:75)
    at Compiler.applyPluginsParallel (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/tapable/lib/Tapable.js:156:14)
    at Compiler.<anonymous> (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/webpack/lib/Compiler.js:463:8)
    at Compiler.applyPluginsAsync (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/tapable/lib/Tapable.js:73:70)
    at Compiler.compile (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/webpack/lib/Compiler.js:456:7)
    at Compiler.<anonymous> (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/webpack/lib/Compiler.js:219:10)
    at Compiler.readRecords (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/webpack/lib/Compiler.js:367:10)
    at Compiler.<anonymous> (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/webpack/lib/Compiler.js:216:9)
    at next (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/tapable/lib/Tapable.js:81:11)
    at Compiler.<anonymous> (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/webpack/lib/CachePlugin.js:34:58)
    at Compiler.applyPluginsAsync (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/tapable/lib/Tapable.js:85:13)
    at Compiler.<anonymous> (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/webpack/lib/Compiler.js:213:8)
    at next (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/tapable/lib/Tapable.js:81:11)
    at Compiler.<anonymous> (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/webpack/lib/node/NodeEnvironmentPlugin.js:23:3)
    at Compiler.applyPluginsAsync (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/tapable/lib/Tapable.js:85:13)
    at Compiler.run (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/webpack/lib/Compiler.js:210:7)
    at /Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/angular-cli/tasks/build-webpack.js:26:29
    at Class.exports.default.Task.extend.run (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/angular-cli/tasks/build-webpack.js:25:16)
    at Class.Command.extend.run (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/angular-cli/commands/build.js:50:26)
    at Class.<anonymous> (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/angular-cli/lib/models/command.js:152:17)
    at tryCatch (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/rsvp/dist/lib/rsvp/-internal.js:215:12)
    at invokeCallback (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/rsvp/dist/lib/rsvp/-internal.js:230:13)
    at publish (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/rsvp/dist/lib/rsvp/-internal.js:198:7)
    at flush (/Users/mwawrusch/Documents/envy-v3/envy-shop/node_modules/rsvp/dist/lib/rsvp/asap.js:85:5)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Flash pluggin keeps blocking

I've been using your pluggin for development for the past half year.
My stack is Meteor - Angular2 and everything used to work really well.

However! Starting last week, I noticed that the embed object appeared in html all of a sudden, an "Pluggin blocked" started appearing (Small square upper right)
screen shot 2017-08-03 at 12 44 32 pm
screen shot 2017-08-03 at 12 44 52 pm

Now, whenever I try to drop an image (using an image file) it opens the file in turn (since flash is not running) I've tried changing all settings to allow, but to no effect
screen shot 2017-08-03 at 12 42 06 pm
screen shot 2017-08-03 at 12 42 17 pm
screen shot 2017-08-03 at 12 42 06 pm

I'm running it on a Mac Os Sierra, and it had been working, I'm guessing new Chrome security settings changed it

dist/FileAPI.flash.swf?r=2.0.21 not found

After reviewing the code, it's found that it did not disable (or expose) the the option to disable usage of flash plugin or expose params to tune the location of the swf.

..../typings/main.d.ts' not found.

I keep getting this error:

ERROR in C:\SAC\sac\Webapp\node_modules\angular2-file-drop\build\src\file-drop.d.ts
(1,1): error TS6053: File 'C:/SAC/sac/Webapp/node_modules/angular2-file-drop/typings/main.d.ts' not found.

I have installed typings on my project, and also have a this in package.json:

  "scripts": {
    "postinstall": "typings install"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.