App Center File Upload Client
raw JSON →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
error TypeError: (0 , appcenter_file_upload_client_1.FileUploadClient) is not a constructor ↓
import { FileUploadClient } from 'appcenter-file-upload-client';. For CommonJS: const { FileUploadClient } = require('appcenter-file-upload-client');. error An error occured: Missing required settings: assetId, assetToken, assetDomain (or similar message) ↓
assetId, assetDomain, and assetToken from the App Center service. error Upload failed with status 401: Unauthorized (or similar authentication error) ↓
assetToken is fresh, correctly obtained from the App Center service, and has appropriate permissions. Check App Center's documentation for token expiry and refresh mechanisms. Warnings
breaking This package is at version 0.1.0 and appears to be abandoned since 2018. It is highly unstable, not actively maintained, and any internal changes to the App Center file upload service are unlikely to be reflected or supported by this client. Production use is strongly discouraged. ↓
gotcha The client requires `assetId`, `assetDomain`, and `assetToken` values that must be securely obtained from the App Center file upload service itself. This library does not handle the acquisition or generation of these authentication tokens. ↓
gotcha File uploads can be unreliable due to network conditions, server issues, or incorrect authentication. The library provides `onMessage` and `onStateChanged` callbacks, but robust error handling and retry mechanisms need to be implemented externally by the consumer. ↓
Install
npm install appcenter-file-upload-client yarn add appcenter-file-upload-client pnpm add appcenter-file-upload-client Imports
- FileUploadClient wrong
const FileUploadClient = require('appcenter-file-upload-client');correctimport { FileUploadClient } from 'appcenter-file-upload-client'; - IFileUploadClientSettings wrong
import { IFileUploadClientSettings } from 'appcenter-file-upload-client';correctimport type { IFileUploadClientSettings } from 'appcenter-file-upload-client'; - IProgress wrong
import { IProgress } from 'appcenter-file-upload-client';correctimport type { IProgress } from 'appcenter-file-upload-client';
Quickstart
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);
});