npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

file-store-lib

v0.8.0

Published

An independent Angular library to upload data files to Firebase Storage.

Downloads

6

Readme

file-store-lib

An independent Angular library to upload data files to Firebase Storage.

Installation

To install this library, run:

$ npm install file-store-lib --save

Consuming the file-store-lib library

Since the library depends on a valid Firebase configuration be setup in your Angular application, you've to setup the firebase configuration as applicable in your AppModule.

Import file-store-lib library in any Angular application by running:

$ npm install file-store-lib

and then from your Angular AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

// Import firebase
import * as firebase from 'firebase';

import { AppComponent } from './app.component';

// Import the library
import { FileUploadModule } from 'file-store-lib';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,

    // Specify the library as an import
    FileUploadModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { 
  constructor() {
    // Setup the Firebase initialization, with appropriate firebase config of your project
    const firebaseConfig = {
      apiKey: 'AIzaSyXxXxYyYyXxXxYyYyXxYyXgt9vmTf123456',
      authDomain: 'your-angular-app.firebaseapp.com',
      databaseURL: 'https://your-angular-app.firebaseio.com',
      projectId: 'your-angular-app',
      storageBucket: 'your-angular-app.appspot.com',
      messagingSenderId: '012345678901'
    };

    firebase.initializeApp(firebaseConfig);
  }
}

Once file-store-lib is imported, you can use its components, directives and pipes in your Angular application:

<!-- You can now use file-store-lib component in app.component.html -->
<md-card>
  <md-card-title>
    {{title}}
  </md-card-title>
  <md-card-content>
    <mlc-file-upload [config]="fileStoreConfig" (onUpload)="captureFileData($event)"></mlc-file-upload>
</md-card-content>
</md-card>

API

FileStoreConfig interface

{
    path: string;
    placeholder?: string;
    accept?: string;
    uploadButtonName?: string;
    cacheMaxAge?: number;
}

FileStoreConfig object holds the path string property which defines the path where the file content to be uploaded in Firebase Storage.

placeholder is an optional string to represent the placeholder on the input element. Default is 'Select a file'.

accept is an optional string which holds the filter to be applied while selecting the file. Refer to W3C standards for valid string values.

uploadButtonName is an optional string to hold the name of the button which triggers the upload action. Default is 'UPLOAD'.

cacheMaxAge (value to be specified in seconds) if not specified is set for 1 year (60 * 60 * 24 * 365) by default, to set the file metadata of CacheControl.

onUpload() onUpload() event is triggered once the File Upload task is completed successfully. The triggered event returns the FileStoreRecord object.

FileStoreRecord

{
    type: string;
    name: string;
    downloadURL: URL;
    createdOn: Date;
    md5Hash: string;
}

Uploading multiple files with Drag & Drop feature

Use the <mlc-file-dnd> element to get the Drag & Drop feature, in place of <mlc-file-upload> element.

<!-- Use file-store-lib component in app.component.html -->
<md-card>
  <md-card-title>
    {{title}}
  </md-card-title>
  <md-card-content>
    <mlc-file-dnd [config]="fileStoreConfig" (onUpload)="captureFileRecords($event)"></mlc-file-dnd>
</md-card-content>
</md-card>

onUpload($event) - would return an array of FileStoreRecords.

FileStoreConfig.accept has no effect on this element, and the user would be free to drag and drop any type of file for upload.

Development

To generate all *.js, *.d.ts and *.metadata.json files:

$ npm run build

To lint all *.ts files:

$ npm run lint

License

All rights reserved. © MedLegalConnect, Prasanna Neelavar