@web-lite/storage
Advanced tools
Comparing version 0.0.3 to 0.0.4
export * from './lib/api'; | ||
export { FileInfo, UploadInfo, OnProgressCallback, CompressorOptions, } from './lib/types'; | ||
export { setUserToken } from './lib/state'; | ||
export { setConfig as config } from './lib/state'; |
@@ -13,6 +13,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.setUserToken = void 0; | ||
exports.config = void 0; | ||
__exportStar(require("./lib/api"), exports); | ||
var state_1 = require("./lib/state"); | ||
Object.defineProperty(exports, "setUserToken", { enumerable: true, get: function () { return state_1.setUserToken; } }); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7OztBQUFBLDRDQUF5QjtBQU96QixxQ0FBMEM7QUFBakMscUdBQUEsWUFBWSxPQUFBIn0= | ||
Object.defineProperty(exports, "config", { enumerable: true, get: function () { return state_1.setConfig; } }); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7OztBQUFBLDRDQUF5QjtBQU96QixxQ0FBaUQ7QUFBeEMsK0ZBQUEsU0FBUyxPQUFVIn0= |
@@ -10,3 +10,3 @@ import { CompressorOptions, FileInfo, OnProgressCallback, UploadInfo } from './types'; | ||
export declare const cancelUpload: (fileId: string) => boolean; | ||
export declare const getDownloadLink: (fileId: string) => string; | ||
export declare const getDirectLink: (fileId: string) => string; | ||
export declare const getInfo: (fileId: string) => Promise<FileInfo>; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getInfo = exports.getDownloadLink = exports.cancelUpload = exports.upload = void 0; | ||
exports.getInfo = exports.getDirectLink = exports.cancelUpload = exports.upload = void 0; | ||
const compression_1 = require("./compression"); | ||
const config_1 = __importDefault(require("./config")); | ||
const helper_1 = require("./helper"); | ||
@@ -14,4 +10,4 @@ const requests_1 = require("./requests"); | ||
const upload = async (file, { name, type = 'file', meta = {}, compression, onProgress, } = {}) => { | ||
const userToken = state_1.getUserToken(); | ||
if (!userToken) | ||
const { authToken } = state_1.getConfig(); | ||
if (!authToken) | ||
throw new Error(NO_USER_TOKEN); | ||
@@ -23,3 +19,3 @@ const fileName = name || file.name; | ||
: file; | ||
const { url, fileId } = await requests_1.getUploadUrl(fileName, fileType, userToken); | ||
const { url, fileId } = await requests_1.getUploadUrl(fileName, fileType, authToken); | ||
const result = await requests_1.uploadFile(processedFile, { | ||
@@ -34,3 +30,3 @@ fileId, | ||
return null; | ||
const { size, contentType, createdAt } = await requests_1.verifyUpload(fileId, userToken); | ||
const { size, contentType, createdAt } = await requests_1.verifyUpload(fileId, authToken); | ||
return { | ||
@@ -54,14 +50,14 @@ fileId, | ||
exports.cancelUpload = cancelUpload; | ||
const getDownloadLink = (fileId) => { | ||
return `${config_1.default.s3Url}/${fileId}`; | ||
const getDirectLink = (fileId) => { | ||
return `${state_1.getConfig().s3Url}/${fileId}`; | ||
}; | ||
exports.getDownloadLink = getDownloadLink; | ||
exports.getDirectLink = getDirectLink; | ||
const getInfo = async (fileId) => { | ||
const userToken = state_1.getUserToken(); | ||
if (!userToken) | ||
const { authToken } = state_1.getConfig(); | ||
if (!authToken) | ||
throw new Error(NO_USER_TOKEN); | ||
const fileInfo = await requests_1.getFileInfo(fileId, userToken); | ||
return Object.assign(Object.assign({}, fileInfo), { directUrl: exports.getDownloadLink(fileId) }); | ||
const fileInfo = await requests_1.getFileInfo(fileId, authToken); | ||
return Object.assign(Object.assign({}, fileInfo), { directLink: exports.getDirectLink(fileId) }); | ||
}; | ||
exports.getInfo = getInfo; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBpLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2xpYi9hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEsK0NBQTZDO0FBQzdDLHNEQUE2QjtBQUM3QixxQ0FBZ0Q7QUFDaEQseUNBQWdGO0FBQ2hGLG1DQUFnRDtBQVFoRCxNQUFNLGFBQWEsR0FBRyxlQUFlLENBQUE7QUFFOUIsTUFBTSxNQUFNLEdBQUcsS0FBSyxFQUN6QixJQUFVLEVBQ1YsRUFDRSxJQUFJLEVBQ0osSUFBSSxHQUFHLE1BQU0sRUFDYixJQUFJLEdBQUcsRUFBRSxFQUNULFdBQVcsRUFDWCxVQUFVLE1BT1IsRUFBRSxFQUNlLEVBQUU7SUFDdkIsTUFBTSxTQUFTLEdBQUcsb0JBQVksRUFBRSxDQUFBO0lBQ2hDLElBQUksQ0FBQyxTQUFTO1FBQUUsTUFBTSxJQUFJLEtBQUssQ0FBQyxhQUFhLENBQUMsQ0FBQTtJQUU5QyxNQUFNLFFBQVEsR0FBRyxJQUFJLElBQUksSUFBSSxDQUFDLElBQUksQ0FBQTtJQUNsQyxNQUFNLFFBQVEsR0FBRyxJQUFJLEtBQUssT0FBTyxDQUFDLENBQUMsQ0FBQyw4QkFBcUIsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQTtJQUUzRSxNQUFNLGFBQWEsR0FDakIsUUFBUSxLQUFLLE9BQU8sSUFBSSxXQUFXO1FBQ2pDLENBQUMsQ0FBQyxNQUFNLDJCQUFhLENBQUMsSUFBSSxFQUFFLFdBQVcsQ0FBQztRQUN4QyxDQ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FNLFlBQVksR0FBRyxDQUFDLE1BQWMsRUFBVyxFQUFFO0lBQ3RELE1BQU0sYUFBYSxHQUFHLGdCQUFRLENBQUMsTUFBTSxDQUFDLENBQUE7SUFDdEMsSUFBSSxDQUFDLGFBQWE7UUFBRSxPQUFPLEtBQUssQ0FBQTtJQUVoQyxhQUFhLEVBQUUsQ0FBQTtJQUNmLE9BQU8sSUFBSSxDQUFBO0FBQ2IsQ0FBQyxDQUFBO0FBTlksUUFBQSxZQUFZLGdCQU14QjtBQUVNLE1BQU0sYUFBYSxHQUFHLENBQUMsTUFBYyxFQUFVLEVBQUU7SUFDdEQsT0FBTyxHQUFHLGlCQUFTLEVBQUUsQ0FBQyxLQUFLLElBQUksTUFBTSxFQUFFLENBQUE7QUFDekMsQ0FBQyxDQUFBO0FBRlksUUFBQSxhQUFhLGlCQUV6QjtBQUVNLE1BQU0sT0FBTyxHQUFHLEtBQUssRUFBRSxNQUFjLEVBQXFCLEVBQUU7SUFDakUsTUFBTSxFQUFFLFNBQVMsRUFBRSxHQUFHLGlCQUFTLEVBQUUsQ0FBQTtJQUNqQyxJQUFJLENBQUMsU0FBUztRQUFFLE1BQU0sSUFBSSxLQUFLLENBQUMsYUFBYSxDQUFDLENBQUE7SUFFOUMsTUFBTSxRQUFRLEdBQUcsTUFBTSxzQkFBVyxDQUFDLE1BQU0sRUFBRSxTQUFTLENBQUMsQ0FBQTtJQUNyRCx1Q0FBWSxRQUFRLEtBQUUsVUFBVSxFQUFFLHFCQUFhLENBQUMsTUFBTSxDQUFDLElBQUU7QUFDM0QsQ0FBQyxDQUFBO0FBTlksUUFBQSxPQUFPLFdBTW5CIn0= |
@@ -8,7 +8,6 @@ "use strict"; | ||
const axios_1 = __importDefault(require("axios")); | ||
const config_1 = __importDefault(require("./config")); | ||
const helper_1 = require("./helper"); | ||
const state_1 = require("./state"); | ||
const getUploadUrl = async (fileName, type, userToken) => { | ||
const { data: { url, fileId }, } = await axios_1.default.get(`${config_1.default.fileServiceUrl}/upload`, { | ||
const { data: { url, fileId }, } = await axios_1.default.get(`${state_1.getConfig().fileServiceUrl}/upload`, { | ||
params: { | ||
@@ -45,3 +44,3 @@ fileName, | ||
const verifyUpload = async (fileId, userToken) => { | ||
const { data } = await axios_1.default.post(`${config_1.default.fileServiceUrl}/verify/${fileId}`, null, { | ||
const { data } = await axios_1.default.post(`${state_1.getConfig().fileServiceUrl}/verify/${fileId}`, null, { | ||
headers: { | ||
@@ -55,3 +54,3 @@ 'X-Auth-Token': userToken, | ||
const getFileInfo = async (fileId, userToken) => { | ||
const { data } = await axios_1.default.get(`${config_1.default.fileServiceUrl}/stat/${fileId}`, { | ||
const { data } = await axios_1.default.get(`${state_1.getConfig().fileServiceUrl}/stat/${fileId}`, { | ||
headers: { | ||
@@ -64,2 +63,2 @@ 'X-Auth-Token': userToken, | ||
exports.getFileInfo = getFileInfo; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVxdWVzdHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbGliL3JlcXVlc3RzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBLGtEQUF5QjtBQUV6QixzREFBNkI7QUFDN0IscUNBQXdDO0FBQ3hDLG1DQUE4QztBQUd2QyxNQUFNLFlBQVksR0FBRyxLQUFLLEVBQy9CLFFBQWdCLEVBQ2hCLElBQVksRUFDWixTQUFpQixFQUN5QixFQUFFO0lBQzVDLE1BQU0sRUFDSixJQUFJLEVBQUUsRUFBRSxHQUFHLEVBQUUsTUFBTSxFQUFFLEdBQ3RCLEdBQUcsTUFBTSxlQUFLLENBQUMsR0FBRyxDQUFDLEdBQUcsZ0JBQU0sQ0FBQyxjQUFjLFNBQVMsRUFBRTtRQUNyRCxNQUFNLEVBQUU7WUFDTixRQUFRO1lBQ1IsSUFBSTtTQUNMO1FBQ0QsT0FBTyxFQUFFO1lBQ1As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LFNBQVM7U0FDMUI7S0FDRixDQUNGLENBQUE7SUFDRCxPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQW5CWSxRQUFBLFlBQVksZ0JBbUJ4QjtBQUVNLE1BQU0sV0FBVyxHQUFHLEtBQUssRUFDOUIsTUFBYyxFQUNkLFNBQWlCLEVBQ1MsRUFBRTtJQUM1QixNQUFNLEVBQUUsSUFBSSxFQUFFLEdBQUcsTUFBTSxlQUFLLENBQUMsR0FBRyxDQUM5QixHQUFHLGlCQUFTLEVBQUUsQ0FBQyxjQUFjLFNBQVMsTUFBTSxFQUFFLEVBQzlDO1FBQ0UsT0FBTyxFQUFFO1lBQ1AsY0FBYyxFQUFFLFNBQVM7U0FDMUI7S0FDRixDQUNGLENBQUE7SUFDRCxPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQWJZLFFBQUEsV0FBVyxlQWF2QiJ9 |
@@ -0,1 +1,2 @@ | ||
import { Config } from './types'; | ||
declare type AbortFunction = () => void; | ||
@@ -5,4 +6,4 @@ export declare const setAbort: (fileId: string, abort: AbortFunction) => void; | ||
export declare const getAbort: (fileId: string) => AbortFunction; | ||
export declare const setUserToken: (token: string) => void; | ||
export declare const getUserToken: () => string; | ||
export declare const setConfig: (values: Config) => void; | ||
export declare const getConfig: () => Config; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getUserToken = exports.setUserToken = exports.getAbort = exports.unsetAbort = exports.setAbort = void 0; | ||
exports.getConfig = exports.setConfig = exports.getAbort = exports.unsetAbort = exports.setAbort = void 0; | ||
const abortFunctions = {}; | ||
let userToken; | ||
let config = { | ||
fileServiceUrl: 'https://dev.weblite.me:3000/s3', | ||
s3Url: 'https://dev.weblite.me:3050/wapp-files', | ||
authToken: null, | ||
}; | ||
const setAbort = (fileId, abort) => { | ||
@@ -16,8 +20,8 @@ abortFunctions[fileId] = abort; | ||
exports.getAbort = getAbort; | ||
const setUserToken = (token) => { | ||
userToken = token; | ||
const setConfig = (values) => { | ||
config = Object.assign(Object.assign({}, config), values); | ||
}; | ||
exports.setUserToken = setUserToken; | ||
const getUserToken = () => userToken; | ||
exports.getUserToken = getUserToken; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhdGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbGliL3N0YXRlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUVBLE1BQU0sY0FBYyxHQUVoQixFQUFFLENBQUE7QUFFTixJQUFJLFNBQWlCLENBQUE7QUFFZCxNQUFNLFFBQVEsR0FBRyxDQUFDLE1BQWMsRUFBRSxLQUFvQixFQUFRLEVBQUU7SUFDckUsY0FBYyxDQUFDLE1BQU0sQ0FBQyxHQUFHLEtBQUssQ0FBQTtBQUNoQyxDQUFDLENBQUE7QUFGWSxRQUFBLFFBQVEsWUFFcEI7QUFFTSxNQUFNLFVBQVUsR0FBRyxDQUFDLE1BQWMsRUFBUSxFQUFFO0lBQ2pELE9BQU8sY0FBYyxDQUFDLE1BQU0sQ0FBQyxDQUFBO0FBQy9CLENBQUMsQ0FBQTtBQUZZLFFBQUEsVUFBVSxjQUV0QjtBQUVNLE1BQU0sUUFBUSxHQUFHLENBQUMsTUFBYyxFQUFpQixFQUFFLENBQ3hELGNBQWMsQ0FBQyxNQUFNLENBQUMsQ0FBQTtBQURYLFFBQUEsUUFBUSxZQUNHO0FBRWpCLE1BQU0sWUFBWSxHQUFHLENBQUMsS0FBYSxFQUFRLEVBQUU7SUFDbEQsU0FBUyxHQUFHLEtBQUssQ0FBQTtBQUNuQixDQUFDLENBQUE7QUFGWSxRQUFBLFlBQVksZ0JBRXhCO0FBRU0sTUFBTSxZQUFZLEdBQUcsR0FBVyxFQUFFLENBQUMsU0FBUyxDQUFBO0FBQXRDLFFBQUEsWUFBWSxnQkFBMEIifQ== | ||
exports.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yxNQUFNLENBQUE7QUFBaEMsUUFBQSxTQUFTLGFBQXVCIn0= |
@@ -9,3 +9,3 @@ import Compressor from 'compressorjs'; | ||
export interface FileInfo extends PartialFileInfo { | ||
directUrl: string; | ||
directLink: string; | ||
} | ||
@@ -27,1 +27,6 @@ export interface UploadInfo { | ||
export declare type CompressorOptions = Compressor.Options; | ||
export interface Config { | ||
fileServiceUrl?: string; | ||
s3Url?: string; | ||
authToken?: string; | ||
} |
export * from './lib/api'; | ||
export { FileInfo, UploadInfo, OnProgressCallback, CompressorOptions, } from './lib/types'; | ||
export { setUserToken } from './lib/state'; | ||
export { setConfig as config } from './lib/state'; |
export * from './lib/api'; | ||
export { setUserToken } from './lib/state'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxXQUFXLENBQUE7QUFPekIsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLGFBQWEsQ0FBQSJ9 | ||
export { setConfig as config } from './lib/state'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxXQUFXLENBQUE7QUFPekIsT0FBTyxFQUFFLFNBQVMsSUFBSSxNQUFNLEVBQUUsTUFBTSxhQUFhLENBQUEifQ== |
@@ -10,3 +10,3 @@ import { CompressorOptions, FileInfo, OnProgressCallback, UploadInfo } from './types'; | ||
export declare const cancelUpload: (fileId: string) => boolean; | ||
export declare const getDownloadLink: (fileId: string) => string; | ||
export declare const getDirectLink: (fileId: string) => string; | ||
export declare const getInfo: (fileId: string) => Promise<FileInfo>; |
import { compressImage } from './compression'; | ||
import config from './config'; | ||
import { inferTypeFromMimeType } from './helper'; | ||
import { getFileInfo, getUploadUrl, uploadFile, verifyUpload } from './requests'; | ||
import { getAbort, getUserToken } from './state'; | ||
import { getAbort, getConfig } from './state'; | ||
const NO_USER_TOKEN = 'NO_USER_TOKEN'; | ||
export const upload = async (file, { name, type = 'file', meta = {}, compression, onProgress, } = {}) => { | ||
const userToken = getUserToken(); | ||
if (!userToken) | ||
const { authToken } = getConfig(); | ||
if (!authToken) | ||
throw new Error(NO_USER_TOKEN); | ||
@@ -16,3 +15,3 @@ const fileName = name || file.name; | ||
: file; | ||
const { url, fileId } = await getUploadUrl(fileName, fileType, userToken); | ||
const { url, fileId } = await getUploadUrl(fileName, fileType, authToken); | ||
const result = await uploadFile(processedFile, { | ||
@@ -27,3 +26,3 @@ fileId, | ||
return null; | ||
const { size, contentType, createdAt } = await verifyUpload(fileId, userToken); | ||
const { size, contentType, createdAt } = await verifyUpload(fileId, authToken); | ||
return { | ||
@@ -45,12 +44,12 @@ fileId, | ||
}; | ||
export const getDownloadLink = (fileId) => { | ||
return `${config.s3Url}/${fileId}`; | ||
export const getDirectLink = (fileId) => { | ||
return `${getConfig().s3Url}/${fileId}`; | ||
}; | ||
export const getInfo = async (fileId) => { | ||
const userToken = getUserToken(); | ||
if (!userToken) | ||
const { authToken } = getConfig(); | ||
if (!authToken) | ||
throw new Error(NO_USER_TOKEN); | ||
const fileInfo = await getFileInfo(fileId, userToken); | ||
return { ...fileInfo, directUrl: getDownloadLink(fileId) }; | ||
const fileInfo = await getFileInfo(fileId, authToken); | ||
return { ...fileInfo, directLink: getDirectLink(fileId) }; | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBpLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2xpYi9hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5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FBSTtRQUNKLElBQUksRUFBRSxRQUFRO1FBQ2QsV0FBVztRQUNYLFNBQVM7S0FDVixDQUFBO0FBQ0gsQ0FBQyxDQUFBO0FBRUQsTUFBTSxDQUFDLE1BQU0sWUFBWSxHQUFHLENBQUMsTUFBYyxFQUFXLEVBQUU7SUFDdEQsTUFBTSxhQUFhLEdBQUcsUUFBUSxDQUFDLE1BQU0sQ0FBQyxDQUFBO0lBQ3RDLElBQUksQ0FBQyxhQUFhO1FBQUUsT0FBTyxLQUFLLENBQUE7SUFFaEMsYUFBYSxFQUFFLENBQUE7SUFDZixPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELE1BQU0sQ0FBQyxNQUFNLGFBQWEsR0FBRyxDQUFDLE1BQWMsRUFBVSxFQUFFO0lBQ3RELE9BQU8sR0FBRyxTQUFTLEVBQUUsQ0FBQyxLQUFLLElBQUksTUFBTSxFQUFFLENBQUE7QUFDekMsQ0FBQyxDQUFBO0FBRUQsTUFBTSxDQUFDLE1BQU0sT0FBTyxHQUFHLEtBQUssRUFBRSxNQUFjLEVBQXFCLEVBQUU7SUFDakUsTUFBTSxFQUFFLFNBQVMsRUFBRSxHQUFHLFNBQVMsRUFBRSxDQUFBO0lBQ2pDLElBQUksQ0FBQyxTQUFTO1FBQUUsTUFBTSxJQUFJLEtBQUssQ0FBQyxhQUFhLENBQUMsQ0FBQTtJQUU5QyxNQUFNLFFBQVEsR0FBRyxNQUFNLFdBQVcsQ0FBQyxNQUFNLEVBQUUsU0FBUyxDQUFDLENBQUE7SUFDckQsT0FBTyxFQUFFLEdBQUcsUUFBUSxFQUFFLFVBQVUsRUFBRSxhQUFhLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQTtBQUMzRCxDQUFDLENBQUEifQ== |
import axios from 'axios'; | ||
import config from './config'; | ||
import { metaToHeaders } from './helper'; | ||
import { setAbort, unsetAbort } from './state'; | ||
import { getConfig, setAbort, unsetAbort } from './state'; | ||
export const getUploadUrl = async (fileName, type, userToken) => { | ||
const { data: { url, fileId }, } = await axios.get(`${config.fileServiceUrl}/upload`, { | ||
const { data: { url, fileId }, } = await axios.get(`${getConfig().fileServiceUrl}/upload`, { | ||
params: { | ||
@@ -40,3 +39,3 @@ fileName, | ||
export const verifyUpload = async (fileId, userToken) => { | ||
const { data } = await axios.post(`${config.fileServiceUrl}/verify/${fileId}`, null, { | ||
const { data } = await axios.post(`${getConfig().fileServiceUrl}/verify/${fileId}`, null, { | ||
headers: { | ||
@@ -49,3 +48,3 @@ 'X-Auth-Token': userToken, | ||
export const getFileInfo = async (fileId, userToken) => { | ||
const { data } = await axios.get(`${config.fileServiceUrl}/stat/${fileId}`, { | ||
const { data } = await axios.get(`${getConfig().fileServiceUrl}/stat/${fileId}`, { | ||
headers: { | ||
@@ -57,2 +56,2 @@ 'X-Auth-Token': userToken, | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVxdWVzdHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbGliL3JlcXVlc3RzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxNQUFNLE9BQU8sQ0FBQTtBQUV6QixPQUFPLE1BQU0sTUFBTSxVQUFVLENBQUE7QUFDN0IsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLFVBQVUsQ0FBQTtBQUN4QyxPQUFPLEVBQUUsUUFBUSxFQUFFLFVBQVUsRUFBRSxNQUFNLFNBQVMsQ0FBQTtBQUc5QyxNQUFNLENBQUMsTUFBTSxZQUFZLEdBQUcsS0FBSyxFQUMvQixRQUFnQixFQUNoQixJQUFZLEVBQ1osU0FBaUIsRUFDeUIsRUFBRTtJQUM1QyxNQUFNLEVBQ0osSUFBSSxFQUFFLEVBQUUsR0FBRyxFQUFFLE1BQU0sRUFBRSxHQUN0QixHQUFHLE1BQU0sS0FBSyxD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FBRyxNQUFNLEtBQUssQ0FBQyxJQUFJLENBQy9CLEdBQUcsU0FBUyxFQUFFLENBQUMsY0FBYyxXQUFXLE1BQU0sRUFBRSxFQUNoRCxJQUFJLEVBQ0o7UUFDRSxPQUFPLEVBQUU7WUFDUCxjQUFjLEVBQUUsU0FBUztTQUMxQjtLQUNGLENBQ0YsQ0FBQTtJQUNELE9BQU8sSUFBSSxDQUFBO0FBQ2IsQ0FBQyxDQUFBO0FBRUQsTUFBTSxDQUFDLE1BQU0sV0FBVyxHQUFHLEtBQUssRUFDOUIsTUFBYyxFQUNkLFNBQWlCLEVBQ1MsRUFBRTtJQUM1QixNQUFNLEVBQUUsSUFBSSxFQUFFLEdBQUcsTUFBTSxLQUFLLENBQUMsR0FBRyxDQUM5QixHQUFHLFNBQVMsRUFBRSxDQUFDLGNBQWMsU0FBUyxNQUFNLEVBQUUsRUFDOUM7UUFDRSxPQUFPLEVBQUU7WUFDUCxjQUFjLEVBQUUsU0FBUztTQUMxQjtLQUNGLENBQ0YsQ0FBQTtJQUNELE9BQU8sSUFBSSxDQUFBO0FBQ2IsQ0FBQyxDQUFBIn0= |
@@ -0,1 +1,2 @@ | ||
import { Config } from './types'; | ||
declare type AbortFunction = () => void; | ||
@@ -5,4 +6,4 @@ export declare const setAbort: (fileId: string, abort: AbortFunction) => void; | ||
export declare const getAbort: (fileId: string) => AbortFunction; | ||
export declare const setUserToken: (token: string) => void; | ||
export declare const getUserToken: () => string; | ||
export declare const setConfig: (values: Config) => void; | ||
export declare const getConfig: () => Config; | ||
export {}; |
const abortFunctions = {}; | ||
let userToken; | ||
let config = { | ||
fileServiceUrl: 'https://dev.weblite.me:3000/s3', | ||
s3Url: 'https://dev.weblite.me:3050/wapp-files', | ||
authToken: null, | ||
}; | ||
export const setAbort = (fileId, abort) => { | ||
@@ -10,6 +14,6 @@ abortFunctions[fileId] = abort; | ||
export const getAbort = (fileId) => abortFunctions[fileId]; | ||
export const setUserToken = (token) => { | ||
userToken = token; | ||
export const setConfig = (values) => { | ||
config = { ...config, ...values }; | ||
}; | ||
export const getUserToken = () => userToken; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhdGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbGliL3N0YXRlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE1BQU0sY0FBYyxHQUVoQixFQUFFLENBQUE7QUFFTixJQUFJLFNBQWlCLENBQUE7QUFFckIsTUFBTSxDQUFDLE1BQU0sUUFBUSxHQUFHLENBQUMsTUFBYyxFQUFFLEtBQW9CLEVBQVEsRUFBRTtJQUNyRSxjQUFjLENBQUMsTUFBTSxDQUFDLEdBQUcsS0FBSyxDQUFBO0FBQ2hDLENBQUMsQ0FBQTtBQUVELE1BQU0sQ0FBQyxNQUFNLFVBQVUsR0FBRyxDQUFDLE1BQWMsRUFBUSxFQUFFO0lBQ2pELE9BQU8sY0FBYyxDQUFDLE1BQU0sQ0FBQyxDQUFBO0FBQy9CLENBQUMsQ0FBQTtBQUVELE1BQU0sQ0FBQyxNQUFNLFFBQVEsR0FBRyxDQUFDLE1BQWMsRUFBaUIsRUFBRSxDQUN4RCxjQUFjLENBQUMsTUFBTSxDQUFDLENBQUE7QUFFeEIsTUFBTSxDQUFDLE1BQU0sWUFBWSxHQUFHLENBQUMsS0FBYSxFQUFRLEVBQUU7SUFDbEQsU0FBUyxHQUFHLEtBQUssQ0FBQTtBQUNuQixDQUFDLENBQUE7QUFFRCxNQUFNLENBQUMsTUFBTSxZQUFZLEdBQUcsR0FBVyxFQUFFLENBQUMsU0FBUyxDQUFBIn0= | ||
export const getConfig = () => config; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhdGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbGliL3N0YXRlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUlBLE1BQU0sY0FBYyxHQUVoQixFQUFFLENBQUE7QUFFTixJQUFJLE1BQU0sR0FBVztJQUNuQixjQUFjLEVBQUUsZ0NBQWdDO0lBQ2hELEtBQUssRUFBRSx3Q0FBd0M7SUFDL0MsU0FBUyxFQUFFLElBQUk7Q0FDaEIsQ0FBQTtBQUVELE1BQU0sQ0FBQyxNQUFNLFFBQVEsR0FBRyxDQUFDLE1BQWMsRUFBRSxLQUFvQixFQUFRLEVBQUU7SUFDckUsY0FBYyxDQUFDLE1BQU0sQ0FBQyxHQUFHLEtBQUssQ0FBQTtBQUNoQyxDQUFDLENBQUE7QUFFRCxNQUFNLENBQUMsTUFBTSxVQUFVLEdBQUcsQ0FBQyxNQUFjLEVBQVEsRUFBRTtJQUNqRCxPQUFPLGNBQWMsQ0FBQyxNQUFNLENBQUMsQ0FBQTtBQUMvQixDQUFDLENBQUE7QUFFRCxNQUFNLENBQUMsTUFBTSxRQUFRLEdBQUcsQ0FBQyxNQUFjLEVBQWlCLEVBQUUsQ0FDeEQsY0FBYyxDQUFDLE1BQU0sQ0FBQyxDQUFBO0FBRXhCLE1BQU0sQ0FBQyxNQUFNLFNBQVMsR0FBRyxDQUFDLE1BQWMsRUFBUSxFQUFFO0lBQ2hELE1BQU0sR0FBRyxFQUFFLEdBQUcsTUFBTSxFQUFFLEdBQUcsTUFBTSxFQUFFLENBQUE7QUFDbkMsQ0FBQyxDQUFBO0FBRUQsTUFBTSxDQUFDLE1BQU0sU0FBUyxHQUFHLEdBQVcsRUFBRSxDQUFDLE1BQU0sQ0FBQSJ9 |
@@ -9,3 +9,3 @@ import Compressor from 'compressorjs'; | ||
export interface FileInfo extends PartialFileInfo { | ||
directUrl: string; | ||
directLink: string; | ||
} | ||
@@ -27,1 +27,6 @@ export interface UploadInfo { | ||
export declare type CompressorOptions = Compressor.Options; | ||
export interface Config { | ||
fileServiceUrl?: string; | ||
s3Url?: string; | ||
authToken?: string; | ||
} |
{ | ||
"name": "@web-lite/storage", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "TypeScript client for Weblite S3 Storage", | ||
@@ -5,0 +5,0 @@ "main": "build/main/index.js", |
@@ -35,3 +35,4 @@ # Weblite Storage Client | ||
declare const getDownloadLink: (fileId: string) => string | ||
// returns direct download link | ||
declare const getDirectLink: (fileId: string) => string | ||
@@ -43,4 +44,10 @@ declare const getInfo: (fileId: string) => Promise<{ | ||
meta: Record<string, unknown>; | ||
directUrl: string; | ||
directLink: string; | ||
}> | ||
declare const config: (values: { | ||
fileServiceUrl?: string | ||
s3Url?: string | ||
authToken?: string | ||
}) => void | ||
``` | ||
@@ -53,2 +60,4 @@ | ||
storage.config({ authToken: 'yourAuthToken' }) | ||
const uploadImage = async (image: File): Promise<void> => { | ||
@@ -55,0 +64,0 @@ const { fileId } = await storage.upload(image, { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41665
493
72