Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@filestack/angular
Advanced tools
filestack-angular Angular component library which allow you to easily integrate powerful filestack-api into your app.
Angular component library which allow you to easily integrate powerful filestack-api into your app.
Table of Contents
filestack-angular is a kind of wrapper on filestack-js sdk which allow you to integrate with filestack service in just a few lines of code. Almost all you are able to do with filestack-js you can also do using this component.
This repository a contains angular workspace with two projects:
filestack-angular
library which contains FilestackAngularModule
published via npmexample
angular app to show examples of using FilestackModule
featuresFilestackAngularModule
consists of
Install it through NPM
npm install filestack-js
npm install @filestack/angular
Include FilestackModule
in app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { FilestackModule } from '@filestack/angular';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FilestackModule
],
bootstrap: [AppComponent]
})
export class AppModule {}
Use in .html file
<ng-picker-overlay
apikey="YOUR_API_KEY">
</ng-picker-overlay>
In the case you would like to import filestack-module
bundle file directly to your app
instead of using npm package you can find it on our cdn:
https://static.filestackapi.com/filestack-angular/{MODULE_VERSION}/filestack-angular.umd.min.js
https://static.filestackapi.com/filestack-angular/{MODULE_VERSION}/filestack-angular.umd.min.js.map
where {MODULE_VERSION} is desired version of this package
Name | Type | Required | Default | Description |
---|---|---|---|---|
apikey | String | True | Filestack api key | |
options | Object | Check pickerOptions | ||
clientOptions.cname | String | Check cname | ||
clientOptions.security | Object(Security) | Check security | ||
clientOptions.sessionCache | Boolean | Check sessionCache | ||
file | InputFile | |||
source | String | Filestack handle or external url. Use it for 'transform', 'remove', 'metadata' or 'preview' action |
Name | Type | Required | Default | Description |
---|---|---|---|---|
uploadSuccess | Subject | A subject that emits on uploadSuccess event | ||
uploadError | Subject | A subject that emits on uploadError event |
The FilestackService
is an adapter on filestack-js client class
and allows you to work with Observables instead of promises.
Methods get the same input params as client class method.
method | return | description |
---|---|---|
init | void | Init filestack client with your apikey |
picker | PickerInstance | Open or close picker instance |
transform | string | Create a transformation url |
retrieve | Observable | Retrieve an info about a filestack handle |
metadata | Observable | Access files via their Filestack handles |
storeURL | Observable | Get info about a filestack handle metadata |
upload | Observable | Upload a file to the Filestack |
remove | Observable | Remove a file from the Filestack |
removeMetadata | Observable | Remove a file only from the Filestack system. The file remains in storage. |
preview | HTMLIFrameElement | Window |
logout | Observable | Clear cloud session from picker procviders |
setClientInstance | ClientInstance | Put an existing client instance into filestack service |
Below you can find some basic examples.
You can also find and try these examples in angular-filestack-example
app
To run it locally type
ng serve filestack-angular-example
then visit
http://localhost:4200/
component.ts
export class AppComponent implements OnInit {
apikey: string;
ngOnInit() {
this.apikey = 'YOUR_API_KEY';
}
}
component.html
<ng-picker-overlay
[apikey]="apikey">
</ng-picker-overlay>
component.ts
export class AppComponent implements OnInit {
apikey: string;
ngOnInit() {
this.apikey = 'YOUR_API_KEY';
this.onSuccess = (res) => console.log('###onSuccess', res);
this.onError = (err) => console.log('###onErr', err);
}
onUploadSuccess(res: object) {
console.log('###uploadSuccess', res);
}
onUploadError(err: any) {
console.log('###uploadError', err);
}
}
component.html
<ng-picker-overlay
[apikey]="apikey"
(uploadSuccess)="onUploadSuccess($event)"
(uploadError)="onUploadError($event)">
<button>Open picker</button>
</ng-picker-overlay>
component.ts
export class AppComponent implements OnInit {
apikey: string;
ngOnInit() {
this.apikey = 'YOUR_API_KEY';
}
onUploadSuccess(res: object) {
console.log('###uploadSuccess', res);
}
onUploadError(err: any) {
console.log('###uploadError', err);
}
}
component.html
<ng-picker-inline
[apikey]="apikey"
(uploadSuccess)="onUploadSuccess($event)"
(uploadError)="onUploadError($event)">
<button>Open picker</button>
</ng-picker-inline>
component.ts
export class AppComponent implements OnInit {
apikey: string;
ngOnInit() {
this.apikey = 'YOUR_API_KEY';
}
onUploadSuccess(res: object) {
console.log('###uploadSuccess', res);
}
onUploadError(err: any) {
console.log('###uploadError', err);
}
}
component.html
<ng-picker-drop-pane
[apikey]="apikey"
(uploadSuccess)="onUploadSuccess($event)"
(uploadError)="onUploadError($event)">
</ng-picker-drop-pane>
component.ts
...
import { TransformOptions } from 'filestack-js';
export class AppComponent implements OnInit {
transformOptions: TransformOptions;
constructor(private filestackService: FilestackService) {}
ngOnInit() {
this.transformOptions = {
resize: {
width: 400
},
sepia: {
tone: 80
}
}
}
}
component.html
<img src="{{'5aYkEQJSQCmYShsoCnZN' | filestackTransform: transformOptions}}">
component.ts
export class AppComponent implements OnInit {
file: any;
constructor(private filestackService: FilestackService) {}
ngOnInit() {
this.filestackService.init('YOUR_API_KEY');
}
fileChanged(e) {
this.file = e.target.files[0];
}
uploadFile() {
this.filestackService.upload(this.file)
.subscribe(res => console.log(res));
}
}
component.html
<input type='file' (change)="fileChanged($event)">
<button (click)="uploadFile()">Upload file</button>
You can find necessary info about avalaible options for actions (Client class methods) at https://filestack.github.io/filestack-js/
After adding changes to FilestackAngularModule
in /projects/filestack-angular/src
you need to build this module
ng build filestack-angular
this command will produce /dist which conatins ready to use filestack module
you can check correctness of it by checking examples from example
app:
Update api key in /projects/example/src/app/app.component.ts
start app locally
ng serve example
Any of your contributions or ideas are more than welcome. Please consider that we follow the conventional commits specification to ensure consistent commit messages and changelog formatting.
FAQs
filestack-angular Angular component library which allow you to easily integrate powerful filestack-api into your app.
The npm package @filestack/angular receives a total of 543 weekly downloads. As such, @filestack/angular popularity was classified as not popular.
We found that @filestack/angular demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
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.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.