
Security News
Vite+ Joins the Push to Consolidate JavaScript Tooling
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
ngx-uploadx
Advanced tools
Angular Resumable Upload Module
npm install ngx-uploadx
//...
import { UploadxModule } from 'ngx-uploadx';
@NgModule({
imports: [
UploadxModule,
// ...
});
// Component code
//...
import { Observable } from 'rxjs';
import { UploadxOptions, UploadState } from 'ngx-uploadx';
@Component({
selector: 'app-home',
templateUrl: `
<input type="file" [uploadx]="options" (uploadxState)="onUpload($event)">
`
})
export class AppHomeComponent {
options: UploadxOptions = { url: `[URL]`};
onUpload(state: Observable<UploadState>) {
state
.subscribe((item: UploadState) => {
console.log(item);
//...
}
}
<input
type="file"
[uploadx]="options"
[uploadxAction]="control"
(uploadxState)="onUpload($event)"
/>
Initializes service. Returns Observable that emits a new value on progress or status changes
// example:
uploadxOptions: UploadxOptions = {
concurrency: 2,
endpoint: `${environment.api}/upload`,
token: () => localStorage.getItem('access_token'),
autoUpload: true,
chunkSize: 1024 * 256 * 8
};
ngOnInit() {
this.uploadService.init(this.uploadxOptions)
.subscribe((item: UploadState) => {
console.log(item);
//...
}
}
Initializes service. Returns Observable that emits the current queue
// example:
@Component({
template: `
<input type="file" uploadx">
<div *ngFor="let item of uploads$ | async">{{item.name}}</div>
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
export class UploadsComponent {
uploads$: Observable<Uploader[]>;
options: UploadxOptions = {
endpoint: `${environment.api}/upload?uploadType=uploadx`,
token: () => localStorage.getItem('access_token'),
}
constructor(private uploadService: UploadxService) {
this.uploads$ = this.uploadService.connect(this.options);
}
Terminate all uploads and clears the queue
Create Uploader for the file and add to the queue
Add files to the upload queue
Send event
// example:
pause(uploadId: string) {
this.uploadService.control({ action: 'pause', uploadId });
}
Uploaders array
Uploadx Events
Name | Defaults? | Description |
---|---|---|
[allowedTypes] | - | Set "accept" attribute |
[autoUpload] | true | Auto upload with global options |
[chunkSize] | 1MiB | If set to > 0 use chunked upload |
[concurrency] | 2 | Limit the number of concurrent uploads |
[headers] | - | Custom headers |
[uploaderClass] | UploaderX | Upload API implementation |
[token] | - | Auth Bearer token / token Getter |
[endpoint] | "/upload" | API URL |
[maxRetryAttempts] | 3 | Maximum number of retries to allow (client errors (4xx)) |
Name | Type | Description |
---|---|---|
file | File | FileAPI File |
name | string | file name |
percentage | number | progress percentage |
remaining | number | ETA |
response | Object | null | response body |
responseStatus | number | response’s status |
size | number | file size |
speed | number | upload speed bytes/sec |
status | UploadStatus | 'added', 'queue', 'uploading', 'complete','retry', 'error', 'cancelled', 'paused' |
uploadId | string | upload id |
URI | string | file URI |
Item custom options, override globals
Name | Type | Description |
---|---|---|
[method] | string | API initial method |
[uploadId] | string | internal upload id ( ReadOnly ) |
[URI] | string | Item URL |
[headers] | { [key: string]: string } | Add custom headers |
[metadata] | any | Add custom data |
[endpoint] | string | Custom url |
Name | Type | Description |
---|---|---|
action | UploadAction | 'uploadAll', 'upload', 'cancel', 'cancelAll', 'pauseAll, 'pause', 'refreshToken' |
[uploadId] | string | upload id ( ReadOnly ) |
[itemOptions] | UploadItem | custom options |
npm run server
npm start
http://localhost:4200/
Run npm run build
to build the lib.
packaged by ng-packagr
Pull requests are welcome!
wil92 | GitHub/wil92 |
---|---|
kukhariev | GitHub/kukhariev |
The MIT License (see the LICENSE file for the full text)
FAQs
Angular Resumable Upload Module
The npm package ngx-uploadx receives a total of 2,299 weekly downloads. As such, ngx-uploadx popularity was classified as popular.
We found that ngx-uploadx demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 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
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
Security News
Ruby Central’s incident report on the RubyGems.org access dispute sparks backlash from former maintainers and renewed debate over project governance.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.