Non-Printable Material

npm

Need private packages and team management tools?Check out npm Orgs. »

appcenter-file-upload-client

0.0.22 • Public • Published

FileUploadClient - client to simplify upload process for AppCenter needs using Microsoft file upload service

Build

  1. npm install
  2. npm run build

Scripts

There are a bunch of scripts in package.json file. Here's what they are and what they do:

Script command What it does
npm run build Compiles the typescript into javascript, creates dist directory.
npm run clean Cleans up any compilation output.
npm run prepublish Clean dist folder, compiles ts and moves js to dist folder, run tslint task.

There will be more over time.

JavaScript API Reference

After importing, file-upload-client module could be used by calling upload method, accepting the following object:

interface IFileUploadClientSettings {
  assetId: string;
  assetDomain: string;
  assetToken: string;
  filePath: string;
  useLogging?: boolean;
 
  onProgressChanged?(progress: IProgress): void;
  onMessage?(errorMessage: string, MessageLevel: MessageLevel): void;
  onStateChanged?(status: FileUploadServiceState): void;
}

NOTE: assetId/assetDomain/assetToken should be provided by File Upload Service.

The upload events adds useful hooks to track upload process.

File Upload client public methods avaliable:

const fileUploadData = {
  assetId: "",
  assetToken: "",
  assetUploadDomian: ""
};

Example Usage:

new FileUploadClient().upload(<IFileUploadClientSettings>{
  onMessage: (uploadMessage: string, messageLevel: MessageLevel) => {
    console.log(`Upload message:  ${uploadMessage}`);
  },
  onProgressChanged: (progressData: IProgress) => {
    console.log(`Upload progress: ${progressData.percentCompleted}`);
  },
  assetId: fileUploadData.assetId,
  assetDomain: fileUploadData.assetUploadDomian,
  assetToken: fileUploadData.assetToken,
  filePath: FILE_PATH
}).then((uploadResult: IUploadResults) => {
  console.log("Wow, upload completed, use this URL to download file: ", uploadResult.downloadUrl);
}).catch((error: FileUploadError) => {
  console.log('An error occured: ', error.message);
});

Example Usage:

const uploadClient = new FileUploadClient({ ... });
uploadClient.upload( { ... });
uploadClient.cancel();

Example Usage:

const uploadClient = new FileUploadClient({ ... });
const isInProgress = uploadClient.isUploadInProgress();

Keywords

none

install

npm i appcenter-file-upload-client

Downloadsweekly downloads

14,033

version

0.0.22

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
Report a vulnerability