Module Not Found: Error: Cant Resolve ng-file-upload-shim in

npm version Downloads Issue Stats Issue Stats
PayPayl donate button Gratipay donate button

ng-file-upload

Lightweight Athwart directive to upload files.

Run into the DEMO folio. Reference docs hither

Migration notes: version 3.0.x version three.1.ten version 3.2.10 version 4.ten.x version 5.ten.10 version 6.10.10 version 6.2.x version 7.0.x version vii.2.10 version 8.0.ten version ix.0.x version ten.0.x version eleven.0.ten version 12.0.x version 12.ane.10 version 12.two.x

Ask questions on StackOverflow under the ng-file-upload tag.
For bug study or feature asking please search through existing issues first so open a new one here. For faster response provide steps to reproduce/versions with a jsfiddle link. If you need back up for your company contact me.
If you similar this plugin requite it a thumbs upward at ngmodules or get me a loving cup of tea . Contributions are welcomed.

Table of Content:

  • Features
  • Install (Manual, Bower, NuGet, NPM)
  • Usage
  • Old Browsers
  • Server Side
    • Samples (Java, Bound, Node.js, Rails, PHP, .Cyberspace)
    • CORS
    • Amazon S3 Upload

Features

  • file upload progress, abolish/abort
  • file drag and drop (html5 only)
  • epitome paste from clipboard and drag and drib from browser pages (html5 only).
  • prototype resize and center crop (native) and user controlled crop through ngImgCrop. See crop sample (html5 only)
  • orientation fix for jpeg epitome files with exif orientation data
  • resumable uploads: interruption/resume upload (html5 merely)
  • native validation support for file blazon/size, epitome width/height/attribute ratio, video/audio elapsing, and ng-required with pluggable custom sync or async validations.
  • show thumbnail or preview of selected images/audio/videos
  • supports CORS and direct upload of file'southward binary data using Upload.$http()
  • plenty of sample server side lawmaking, bachelor on nuget
  • on demand flash FileAPI shim loading no extra load for html5 browsers.
  • HTML5 FileReader.readAsDataURL shim for IE8-9
  • available on npm, bower, meteor, nuget

Install

  • Manual: download latest from here
  • Bower:
    • bower install ng-file-upload-shim --salvage(for not html5 suppport)
    • bower install ng-file-upload --save
  • NuGet: PM> Install-Package angular-file-upload (thank you to Georgios Diamantopoulos)
  • NPM: npm install ng-file-upload
                

< script src = " athwart(.min).js " > < / script >

< script src = " ng-file-upload-shim(.min).js " > < / script >

< script src = " ng-file-upload(.min).js " > < / script >

Usage

Samples:

  • Upload with class submit and validations: http://jsfiddle.net/danialfarid/maqbzv15/1118/
  • Upload multiple files ane by one on file select: http://jsfiddle.cyberspace/danialfarid/2vq88rfs/136/
  • Upload multiple files in one request on file select (html5 only): http://jsfiddle.cyberspace/danialfarid/huhjo9jm/5/
  • Upload single file on file select: http://jsfiddle.cyberspace/danialfarid/0mz6ff9o/135/
  • Drib and upload with $sentinel: http://jsfiddle.net/danialfarid/s8kc7wg0/400/
  • Image Crop and Upload http://jsfiddle.net/danialfarid/xxo3sk41/590/
                

< script src = " athwart.min.js " > < / script >

< script src = " ng-file-upload-shim.min.js " > < / script >

< script src = " ng-file-upload.min.js " > < / script >

Upload on form submit or push button click

< form ng-app = " fileUpload " ng-controller = " MyCtrl " name = " form " >

  Single Image with validations

< div grade = " button " ngf-select ng-model = " file " name = " file " ngf-pattern = " 'image/*' "

ngf-accept = " 'image/*' " ngf-max-size = " 20MB " ngf-min-height = " 100 "

ngf-resize = " {width: 100, tiptop: 100} " > Select </ div >

  Multiple files

< div form = " push " ngf-select ng-model = " files " ngf-multiple = " true " > Select </ div >

  Drop files: < div ngf-drop ng-model = " files " grade = " driblet-box " > Drop </ div >

< push button type = " submit " ng-click = " submit() " > submit </ push button >

</ form >

Upload correct away after file selection:

< div form = " button " ngf-select = " upload($file) " > Upload on file select </ div >

< div form = " button " ngf-select = " uploadFiles($files) " multiple = " multiple " > Upload on file select </ div >

  Driblet File:

< div ngf-drop = " uploadFiles($files) " class = " drop-box "

ngf-drag-over-class = " 'dragover' " ngf-multiple = " true "

ngf-pattern = " 'image/*,application/pdf' " > Drop Images or PDFs files here </ div >

< div ngf-no-file-drop > File Drag/Drop is not supported for this browser </ div >

Prototype thumbnail: < img ngf-thumbnail = " file || '/thumb.jpg' " >

Audio preview: < audio controls ngf-src = " file " > < / audio >

Video preview: < video controls ngf-src = " file " > < / video >

Javascript code:

                

var  app = angular . module ( ' fileUpload ' , [ ' ngFileUpload ' ] ) ;

app . controller ( ' MyCtrl ' , [ ' $scope ' , ' Upload ' , function ( $scope , Upload ) {

$scope . submit = function ( ) {

if ( $telescopic . form . file . $valid && $scope . file ) {

$scope . upload ( $scope . file ) ;

}

} ;

$scope . upload = function ( file ) {

Upload . upload ( {

            url : ' upload/url ' ,

            data : { file :  file , ' username ' : $scope . username }

} ) . so ( function ( resp ) {

console . log ( ' Success ' + resp . config . information . file . name + ' uploaded. Response: ' + resp . data ) ;

} , function ( resp ) {

console . log ( ' Error status: ' + resp . status ) ;

} , part ( evt ) {

var  progressPercentage = parseInt ( 100 . 0 * evt . loaded / evt . total ) ;

console . log ( ' progress: ' +  progressPercentage + ' % ' + evt . config . information . file . proper name ) ;

} ) ;

} ;

$scope . uploadFiles = office ( files ) {

if ( files && files . length ) {

for ( var  i = 0 ;  i < files . length ;  i ++ ) {

Upload . upload ( { ... ,  data : { file :  files [ i ] } , ... } ) ... ;

}

Upload . upload ( { ... ,  information : { file :  files } , ... } ) ... ;

}

}

} ] ) ;

Full reference

File select and drop

At least ane of the ngf-select or ngf-drib are mandatory for the plugin to link to the chemical element. ngf-select just attributes are marked with * and ngf-drop but attributes are marked with +.

                

< div | button | input type = " file " | ngf-select | ngf-drib ...

ngf-select = " " or " upload($files, ...) "  // called when files are selected or cleared

ngf-drop = " " or " upload($files, ...) "  // called when files being dropped

    // You tin use ng-model or ngf-change instead of specifying role for ngf-drop and ngf-select

    // function parameters are the same as ngf-alter

ngf-change = " upload($files, $file, $newFiles, $duplicateFiles, $invalidFiles, $event) "

    // called when files are selected , dropped , or cleared

ng-model = " myFiles "  // binds the valid selected / dropped file or files to the scope model

    // could exist an array or single file depending on ngf-multiple and ngf-keep values .

ngf-model-options = " {updateOn: 'change click drib dropUrl paste', allowInvalid: fake, debounce: 0} "

    // updateOn could be used to disable resetting on click , or updating on paste , browser image drib , etc .

    // allowInvalid default is simulated could permit invalid files in the model

    // debouncing will postpone model update  ( miliseconds ). See angular ng-model-options for more details .

ngf-model-invalid = " invalidFile(s) "  // binds the invalid selected / dropped file or files to this model .

ngf-earlier-model-alter = " beforeChange($files, ...) "  // chosen later file select / drib and before

    // model change , validation and resize is processed

ng-disabled = " boolean "  // disables this element

ngf-select-disabled = " boolean "  // default simulated , disables file select on this element

ngf-drop-disabled = " boolean "  // default fake , disables file drop on this chemical element

ngf-multiple = " boolean "  // default simulated , allows selecting multiple files

ngf-keep = " true|simulated|'distinct' "  // default faux , keep the previous ng-model files and

    // append the new files . " 'distinct' " removes duplicate files

    // $ newFiles and  $ duplicateFiles are set in ngf-alter / select / drop functions .

ngf-gear up-orientation = " boolean "  // default fake , would rotate the jpeg image files that have

    // exif orientation data . See  # 745 . Could exist a boolean part like shouldFixOrientation ($ file )

    // to make up one's mind wethere to fix that file or not .

  * ngf-capture = " 'camera' " or " 'other' "  // allows mobile devices to capture using camera

  * ngf-accept = " 'prototype/*' "  // standard HTML accept attr , browser specific select popup window

  + ngf-allow-dir = " boolean "  // default true , allow dropping files only for Chrome webkit browser

  + ngf-include-dir = " boolean "  // default false , include directories in the dropped file array .

    // You can detect if they are directory or not past checking the type  = == ' directory ' .

  + ngf-drag-over-class = " {pattern: 'paradigm/*', accept:'acceptClass', reject:'rejectClass', delay:100} "

or " 'myDragOverClass' " or " calcDragOverClass($event) "

    // default " dragover " . drag over css form behaviour . could exist a cord , a function

    // returning form name or a json object .

    // have / reject class merely works in Chrome , validating merely the file mime type .

    // if pattern is not specified ngf-pattern will exist used . Come across following docs for more than info .

  + ngf-drag = " drag($isDragging, $course, $outcome) "  // function chosen on drag over / leave events .

    // $ isDragging: boolean truthful if is dragging over ( dragover ), simulated if drag has left  ( dragleave )

    // $ class is the grade that is being prepare for the element calculated by ngf-drag-over-form

  + ngf-drib-available = " dropSupported "  // set the value of telescopic model to true or false based on file

                                     // elevate & drop support for this browser

  + ngf-stop-propagation = " boolean "  // default false , whether to propagate drag / drop events .

  + ngf-hibernate-on-drop-not-available = " boolean "  // default false , hides element if file elevate & drop is non

  + ngf-enable-firefox-paste = " boolean "  // * experimental * default faux , enable firefox image paste past making chemical element contenteditable

ngf-resize = " {width: 100, height: 100, quality: .eight, blazon: 'image/jpeg',

               ratio: '1:2', centerCrop: true, pattern='.jpg', restoreExif: imitation} "

or resizeOptions () // a function returning a promise which resolves into the options .

    // resizes the image to the given width / tiptop or ratio . Quality is optional between 0 . 1 and 1 . 0 ),

    // type is optional convert information technology to the given image type format .

    // centerCrop true will center crop the paradigm if it does not fit within the given width / acme or ratio .

    // centerCrop simulated  ( default ) will non crop the image and will fit information technology within the given width / elevation or ratio

    // and so the resulting prototype width  ( or height ) could be less than given width  ( or height ).

    // pattern is to resize simply the files that their name or type matches the pattern similar to ngf-pattern .

    // restoreExif boolean default truthful , volition restore exif info on the resized image .

ngf-resize-if = " $width > 1000 || $height > 1000 " or " resizeCondition($file, $width, $meridian) "

    // apply ngf-resize only if this function returns true . To filter specific images to be resized .

ngf-validate-after-resize = " boolean "  // default false , if true all validation will exist run after

    // the images are beingness resized , so any validation error before resize will be ignored .

  // validations:

ngf-max-files = " 10 "  // maximum number of files allowed to be selected or dropped , validate error name: maxFiles

ngf-blueprint = " '.pdf,.jpg,video/*,!.jog' "  // comma separated wildcard to filter file names and types allowed

              // you can exclude specific files by  ! at the showtime .

              // validate fault name: blueprint

ngf-min-size , ngf-max-size , ngf-max-total-size = " 100 " in bytes or " '10KB' " or " '10MB' " or " '10GB' "

              // validate as form . file .$ fault . maxSize = true and file .$ error = ' maxSize '

              // ngf-max-total-size is for multiple file select and validating the total size of all files .

ngf-min-meridian , ngf-max-height , ngf-min-width , ngf-max-width = " g " in pixels simply images

              // validate error names: minHeight , maxHeight , minWidth , maxWidth

ngf-ratio = " 8:10,1.6 "  // list of comma separated valid aspect ratio of images in float or 2:3 format

              // validate fault name: ratio

ngf-min-ratio , ngf-max-ratio = " viii:x "  // min or max immune aspect ratio for the image .

ngf-dimensions = " $width > 1000 || $acme > 1000 " or " validateDimension($file, $width, $height) "

              // validate the prototype dimensions , validate error proper name: dimensions

ngf-min-duration , ngf-max-duration = " 100.5 " in seconds or " '10s' " or " '10m' " or " '10h' " simply audio , video

              // validate fault proper noun: maxDuration

ngf-duration = " $elapsing > thou " or " validateDuration($file, $duration) "

              // validate the media duration , validate error proper name: elapsing

ngf-validate = " {size: {min: 10, max: '20MB'}, width: {min: 100, max:10000}, height: {min: 100, max: 300}

                ratio: '2x1', duration: {min: '10s', max: '5m'}, pattern: '.jpg'} "

shorthand grade for higher up validations in i place .

ngf-validate-fn = " validate($file) "  // custom validation role , return boolean or string containing the error .

              // validate error proper name: validateFn

ngf-validate-async-fn = " validate($file) "  // custom validation role , return a promise that resolve to

              // boolean or string containing the error . validate error name: validateAsyncFn

ngf-validate-strength = " boolean "  // default simulated , if true file .$ error volition be gear up if the dimension or duration

              // values for validations cannot be calculated for example image load mistake or unsupported video by the browser .

              // by default it would assume the file is valid if the duration or dimension cannot exist calculated by the browser .

ngf-ignore-invalid = " 'pattern maxSize' "  // ignore the files that fail the specified validations . They will

              // just be ignored and will not show upward in ngf-model-invalid or make the form invalid .

              // space separated listing of validate fault names .

ngf-run-all-validations = " boolean "  // default false . Runs all the specified validate directives . Past default

              // once a validation fails for a file information technology would cease running other validations for that file .

> Upload/Driblet </ div >

< div |... ngf-no-file-drop > File Drag/drop is not supported </ div >

// filter to convert the file to base64 data url.

< a href = " file | ngfDataUrl " > image </ a >

File preview

                

< img | audio | video | div

  * ngf-src = " file "  // To preview the selected file , sets src attribute to the file information url .

  * ngf-groundwork = " file "  // sets groundwork-epitome manner to the file data url .

ngf-resize = " {width: 20, meridian: 20, quality: 0.9} "  // merely for paradigm resizes the image earlier setting it

             // as src or groundwork image . quality is optional .

ngf-no-object-url = " true or fake "  // encounter  # 887 to force base64 url generation instead of object url . Default simulated

>

< div | bridge |...

 * ngf-thumbnail = " file "  // Generates a thumbnail version of the epitome file

ngf-size = " {width: 20, elevation: xx, quality: 0.9} " the image will be resized to this size

        // if non specified will be resized to this element ` s client width and height .

ngf-as-background = " boolean "  // if true it will ready the groundwork epitome style instead of src attribute .

>

Upload service:

                

var  upload = Upload . upload ( {

* url : ' server/upload/url ' ,

* information : { key :  file ,  otherInfo :  uploadInfo } ,

  objectKey : ' [k] '  or ' .chiliad '

  arrayKey : ' [i] '  or ' [] '  or ' .i '  or ' '

  method : ' POST '  or ' PUT ' ( html5 ) ,  default POST ,

  headers : { ' Authorization ' : ' xxx ' } ,

  withCredentials :  boolean ,

  resumeSizeUrl : ' /uploaded/size/url?file= ' + file . proper name

resumeSizeResponseReader : office ( data ) { return information . size ; }

resumeSize : function ( ) { return  promise ; }

  resumeChunkSize : 10000  or ' 10KB '  or ' 10MB '

  disableProgress :  boolean

...  and all other angular $http ( )  options could be used here .

} )

upload . and then ( part ( resp ) {

panel . log ( ' file ' + resp . config . data . file . name + ' is uploaded successfully. Response: ' + resp . data ) ;

} , function ( resp ) {

} , part ( evt ) {

console . log ( ' progress: ' + parseInt ( 100 . 0 * evt . loaded / evt . total ) + ' % file : ' + evt . config . data . file . proper name ) ;

} ) ;

upload . take hold of ( errorCallback ) ;

upload . finally ( callback ,  notifyCallback ) ;

upload . xhr ( function ( xhr ) {

xhr . upload . addEventListener ( ... )

} ) ;

upload . abort ( ) ;

Upload . http ( {

  url : ' /server/upload/url ' ,

  headers : {

' Content-Type ' : file . type

} ,

  data :  file

} )

Upload . setDefaults ( { ngfMinSize : 20000 ,  ngfMaxSize : 20000000 , ... } )

Upload . defaults . blobUrlsMaxMemory = 268435456

Upload . defaults . blobUrlsMaxQueueSize = 200

Upload . base64DataUrl ( files ) . and then ( function ( urls ) { ... } ) ;

Upload . dataUrl ( file ,  boolean ) . so ( office ( url ) { ... } ) ;

Upload . imageDimensions ( file ) . then ( role ( dimensions ) { panel . log ( dimensions . width , dimensions . summit ) ; } ) ;

Upload . mediaDuration ( file ) . and so ( role ( durationInSeconds ) { ... } ) ;

Upload . resize ( file ,  options ) . so ( function ( resizedFile ) { ... } ) ;

Upload . isResizeSupported ( )

Upload . isResumeSupported ( )

Upload . rename ( file ,  newName )

Upload . jsonBlob ( obj )

Upload . json ( obj )

var  hulk = upload . dataUrltoBlob ( dataurl ,  name ) ;

Upload . isUploadInProgress ( )  boolean

Upload . urlToBlob ( url ) . then ( function ( hulk ) { ... } ) ;

Upload . isFile ( obj ) ;

Upload . applyExifRotation ( file ) . then ( ... )

ng-model The model value volition be a single file instead of an assortment if all of the followings are true:

  • ngf-multiple is not set or is resolved to imitation.
  • multiple aspect is not set on the element
  • ngf-keep is not set or is resolved to false.

validation When any of the validation directives specified the form validation volition take place and you can access the value of the validation using myForm.myFileInputName.$error.<validate mistake proper name> for example form.file.$error.pattern. If multiple file selection is allowed y'all tin can specify ngf-model-invalid="invalidFiles" to assing the invalid files to a model and find the fault of each individual file with file.$error and clarification of it with file.$errorParam. You can use angular ngf-model-options to allow invalid files to exist set to the ng-model ngf-model-options="{allowInvalid: true}".

Upload multiple files: Only for HTML5 FormData browsers (not IE8-9) you take an array of files or more than than 1 file in your data to ship them all in one request . Non-html5 browsers due to flash limitation will upload each file one past i in a separate request. You should iterate over the files and ship them one by i for a cross browser solution.

drag and drop styling: For file drag and drop, ngf-drag-over-class could be used to manner the drop zone. It can be a function that returns a class proper name based on the $upshot. Default is "dragover" string. Only in chrome It could be a json object {have: 'a', 'reject': 'r', pattern: 'image/*', delay: ten} that specify the class name for the accepted or rejected drag overs. The pattern specified or ngf-blueprint will be used to validate the file'due south mime-type since that is the only property of the file that is reported past the browser on drag. So you cannot validate the file proper name/extension, size or other validations on drag. At that place is as well some limitation on some file types which are non reported by Chrome. delay default is 100, and is used to fix css3 transition problems from dragging over/out/over #277.

Upload.setDefaults(): If yous have many file selects or drops y'all can set the default values for the directives past calling Upload.setDefaults(options). options would be a json object with directive names in camelcase and their default values.

Resumable Uploads: The plugin supports resumable uploads for large files. On your server you need to keep rail of what files are existence uploaded and how much of the file is uploaded.

  • url upload endpoint demand to reassemble the file chunks past appending uploading content to the end of the file or correct chunk position if it already exists.
  • resumeSizeUrl server endpoint to render uploaded file size so far on the server to be able to resume the upload from where information technology is ended. It should render nada if the file has not been uploaded all the same.
    A Go request volition be made to that url for each upload to determine if part of the file is already uploaded or not. You demand a unique way of identifying the file on the server and then yous tin can pass the file name or generated id for the file as a request parameter.
    By default it volition assume that the response content is an integer or a json object with size integer property. If yous return other formats from the endpoint you lot can specify resumeSizeResponseReader function to return the size value from the response. Alternatively instead of resumeSizeUrl you tin use resumeSize function which returns a promise that resolves to the size of the uploaded file so far. Make sure when the file is fully uploaded without whatsoever mistake/arrest this endpoint returns zero for the file size if you want to allow the user to upload the same file again. Or optionally you could take a restart endpoint to set that back to zero to permit re-uploading the aforementioned file.
  • resumeChunkSize optionally y'all can specify this to upload the file in chunks to the server. This will permit uploading to GAE or other servers that have file size limitation and trying to upload the whole request before passing it for internal processing.
    If this choice is gear up the requests volition have the following extra fields: _chunkSize, _currentChunkSize, _chunkNumber (nada starting), and _totalSize to help the server to write the uploaded chunk to the right position. Uploading in chunks could slow down the overall upload time specially if the chunk size is besides minor. When y'all provide resumeChunkSize option ane of the resumeSizeUrl or resumeSize is mandatory to know how much of the file is uploaded and then far.

Quondam browsers

For browsers not supporting HTML5 FormData (IE8, IE9, ...) FileAPI module is used. Note: You need Flash installed on your browser since FileAPI uses Flash to upload files.

These two files FileAPI.min.js, FileAPI.wink.swf volition be loaded past the module on demand (no need to be included in the html) if the browser does not supports HTML5 FormData to avoid extra load for HTML5 browsers. You can place these two files beside angular-file-upload-shim(.min).js on your server to be loaded automatically from the same path or you lot can specify the path to those files if they are in a different path using the post-obit script:

                

< script >

    FileAPI = {

        jsPath : ' /js/FileAPI.min.js/folder/ ' ,

        jsUrl : ' yourcdn.com/js/FileAPI.min.js ' ,

        staticPath : ' /flash/FileAPI.flash.swf/folder/ ' ,

        flashUrl : ' yourcdn.com/js/FileAPI.flash.swf ' ,

}

</ script >

< script src = " athwart-file-upload-shim.min.js " > < / script > ...

Old browsers known bug:

  • Because of a Wink limitation/problems if the server doesn't send whatever response trunk the status code of the response volition be ever 204 'No Content'. Then if yous accept access to your server upload code at to the lowest degree return a character in the response for the status code to work properly.
  • Custom headers will not work due to a Wink limitation #111 #224 #129
  • Due to Flash bug #92 Server HTTP fault code 400 volition be returned equally 200 to the client. So avoid returning 400 on your server side for upload response otherwise it will exist treated as a success response on the client side.
  • In case of an error response (http code >= 400) the custom error message returned from the server may not be bachelor. For some mistake codes flash just provide a generic error message and ignores the response text. #310
  • Older browsers won't permit PUT requests. #261

Server Side

  • Java You can observe the sample server code in Java/GAE hither
  • Jump MVC Wiki Sample provided by zouroto
  • Node.js Wiki Sample provided past chovy. Another wiki using Express four.0 and the Multiparty provided by Jonathan White
  • Rails
    • Wiki Sample provided by guptapriyank.
    • Web log post provided past Coshx Labs.
    • Track progress outcome: If your server is Track and Apache you may need to modify server configurations for the server to support upload progress. See #207
  • PHP Wiki Sample and related issue only one file in $_FILES when uploading multiple files
  • .Net
    • Demo showing how to use ng-file-upload with Asp.Internet Web Api.
    • Sample client and server code demo/C# provided by AtomStar

CORS

To back up CORS upload your server needs to allow cross domain requests. You tin can achieve that by having a filter or interceptor on your upload file server to add CORS headers to the response similar to this: (sample java code)

                

httpResp . setHeader ( " Admission-Control-Let-Methods " , " POST, PUT, OPTIONS " ) ;

httpResp . setHeader ( " Access-Control-Allow-Origin " , " your.other.server.com " ) ;

httpResp . setHeader ( " Access-Command-Allow-Headers " , " Content-Type " ) ) ;

For non-HTML5 IE8-9 browsers you would also need a crossdomain.xml file at the root of your server to let CORS for flash: (sample xml)

                

< cross-domain-policy >

< site-command permitted-cross-domain-policies = " all " />

< permit-access-from domain = " athwart-file-upload.appspot.com " />

< permit-http-request-headers-from domain = " * " headers = " * " secure = " false " />

</ cross-domain-policy >

Amazon AWS S3 Upload

For Amazon hallmark version iv run across this comment

The demo page has an option to upload to S3. Hither is a sample config options:

                

Upload . upload ( {

    url : ' https://angular-file-upload.s3.amazonaws.com/ ' ,

    method : ' Mail ' ,

    data : {

        key : file . name ,

        AWSAccessKeyId : < YOUR AWS  AccessKey Id > ,

        acl : ' private ' ,

        policy : $telescopic . policy ,

        signature : $telescopic . signature ,

" Content-Type " : file . blazon != ' ' ? file . type : ' awarding/octet-stream ' ,

        filename : file . proper noun ,

        file :  file

}

} ) ;

This commodity explains more about these fields and provides instructions on how to generate the policy and signature using a server side tool. These two values are generated from the json policy document which looks similar this:

                

{

" expiration " : " 2020-01-01T00:00:00Z " ,

" weather " : [

{ " saucepan " : " angular-file-upload " } ,

[ " starts-with " , " $key " , " " ] ,

{ " acl " : " individual " } ,

[ " starts-with " , " $Content-Type " , " " ] ,

[ " starts-with " , " $filename " , " " ] ,

[ " content-length-range " , 0 , 524288000 ]

]

}

The demo page provide a helper tool to generate the policy and signature from you from the json policy document. Note: Delight use https protocol to admission demo page if you are using this tool to generate signature and policy to protect your aws secret central which should never be shared.

Make sure that y'all provide upload and CORS postal service to your bucket at AWS -> S3 -> bucket name -> Properties -> Edit bucket policy and Edit CORS Configuration. Samples of these 2 files:

                

{

" Version " : " 2012-10-17 " ,

" Statement " : [

{

" Sid " : " UploadFile " ,

" Result " : " Allow " ,

" Principal " : {

" AWS " : " arn:aws:iam::xxxx:user/thirty "

} ,

" Activity " : [

" s3:GetObject " ,

" s3:PutObject "

] ,

" Resource " : " arn:aws:s3:::angular-file-upload/* "

} ,

{

" Sid " : " crossdomainAccess " ,

" Effect " : " Let " ,

" Principal " : " * " ,

" Action " : " s3:GetObject " ,

" Resource " : " arn:aws:s3:::angular-file-upload/crossdomain.xml "

}

]

}

                

<? xml  version = " 1.0 "  encoding = " UTF-8 " ?>

< CORSConfiguration xmlns = " http://s3.amazonaws.com/doc/2006-03-01/ " >

< CORSRule >

< AllowedOrigin > http://angular-file-upload.appspot.com </ AllowedOrigin >

< AllowedMethod > POST </ AllowedMethod >

< AllowedMethod > GET </ AllowedMethod >

< AllowedMethod > HEAD </ AllowedMethod >

< MaxAgeSeconds > 3000 </ MaxAgeSeconds >

< AllowedHeader > * </ AllowedHeader >

</ CORSRule >

</ CORSConfiguration >

For IE8-9 flash polyfill you need to have a crossdomain.xml file at the root of you S3 bucket. Make sure the content-type of crossdomain.xml is text/xml and you provide read admission to this file in your saucepan policy.

Y'all can also take a look at https://github.com/nukulb/s3-athwart-file-upload for another example with this fix.

jewellhapen1962.blogspot.com

Source: https://www.npmjs.com/package/ng-file-upload

0 Response to "Module Not Found: Error: Cant Resolve ng-file-upload-shim in"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel