App Center File Upload Client

0.1.0 · abandoned · verified Tue Apr 21

This package, `appcenter-file-upload-client`, provides a client-side JavaScript/TypeScript library designed to streamline the file upload process specifically for Microsoft App Center services. It abstracts the complexities of interacting with the Microsoft file upload service, offering a programmatic interface to upload files with progress tracking, cancellation capabilities, and event hooks for messages and state changes. Currently at version 0.1.0, this package is an early-stage release, and given its last commit date in 2018, it is considered abandoned and unlikely to receive further updates or stability guarantees. Its primary differentiator is its direct integration with App Center's internal file upload mechanisms, requiring `assetId`, `assetDomain`, and `assetToken` values obtained from the App Center service itself.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates initializing `FileUploadClient`, performing an upload with progress and message callbacks, and handling success or error with required environment variables.

import { FileUploadClient } from 'appcenter-file-upload-client';
import type { IProgress, MessageLevel, IUploadResults, FileUploadError } from 'appcenter-file-upload-client';

const FILE_PATH = process.env.UPLOAD_FILE_PATH ?? './sample.txt';

// These values must be obtained securely from the App Center Upload Service
// and are required for authentication and targeting the correct upload destination.
const fileUploadData = {
  assetId: process.env.APPCENTER_ASSET_ID ?? '',
  assetToken: process.env.APPCENTER_ASSET_TOKEN ?? '',
  assetUploadDomian: process.env.APPCENTER_ASSET_DOMAIN ?? ''
};

if (!fileUploadData.assetId || !fileUploadData.assetToken || !fileUploadData.assetUploadDomian || !FILE_PATH) {
  console.error('Please set UPLOAD_FILE_PATH, APPCENTER_ASSET_ID, APPCENTER_ASSET_TOKEN, and APPCENTER_ASSET_DOMAIN environment variables.');
  process.exit(1);
}

new FileUploadClient().upload({
  onMessage: (uploadMessage: string, messageLevel: MessageLevel) => {
    console.log(`[${MessageLevel[messageLevel]}] Upload message: ${uploadMessage}`);
  },
  onProgressChanged: (progressData: IProgress) => {
    console.log(`Upload progress: ${progressData.percentCompleted}%`);
  },
  assetId: fileUploadData.assetId,
  assetDomain: fileUploadData.assetUploadDomian,
  assetToken: fileUploadData.assetToken,
  filePath: FILE_PATH,
  useLogging: true
}).then((uploadResult: IUploadResults) => {
  console.log("File upload completed. Download URL:", uploadResult.downloadUrl);
}).catch((error: FileUploadError) => {
  console.error('An error occurred during upload:', error.message);
  process.exit(1);
});

view raw JSON →