Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@expressms/smartapp-sdk",
"version": "1.13.0-alpha.12",
"version": "1.14.0-alpha.1",
"description": "Smartapp SDK",
"main": "build/main/index.js",
"typings": "build/main/index.d.ts",
Expand Down
9 changes: 9 additions & 0 deletions src/lib/client/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import bridge from '@expressms/smartapp-bridge'
import {
ERROR_CODES,
File,
FILE_MEDIA_QUALITY,
METHODS,
StatusResponse,
UploadFilesTypeResponse,
Expand Down Expand Up @@ -31,14 +32,17 @@ const openFile = async (file: File): Promise<StatusResponse> => {
* Upload single file with client
* @param mimeType Mime type of allowed files
* @param maxSize Max file size in bytes
* @param mediaQuality File media quality (For example: low mediaQuality - high compression ratio on client)
* @returns Promise that'll be fullfilled with file metadata on success, otherwise rejected with reason
*/
const uploadFile = async ({
mimeType,
maxSize,
mediaQuality,
}: {
mimeType: string
maxSize?: number
mediaQuality?: FILE_MEDIA_QUALITY | null
}): Promise<UploadFileTypeResponse> => {
if (!bridge) return Promise.reject(ERROR_CODES.NO_BRIDGE)

Expand All @@ -47,6 +51,7 @@ const uploadFile = async ({
params: {
type: mimeType,
maxSize,
mediaQuality,
},
timeout: FILE_LOAD_TIMEOUT,
})
Expand All @@ -59,16 +64,19 @@ const uploadFile = async ({
* @param mimeType Mime type of allowed files
* @param maxSize Max file size in bytes
* @param totalSize Total files size in bytes
* @param mediaQuality File media quality (For example: low mediaQuality - high compression ratio on client)
* @returns Promise that'll be fullfilled with files metadata on success, otherwise rejected with reason
*/
const uploadFiles = async ({
mimeType,
maxSize,
totalSize,
mediaQuality,
}: {
mimeType: string
maxSize?: number,
totalSize?: number,
mediaQuality?: FILE_MEDIA_QUALITY | null
}): Promise<UploadFilesTypeResponse> => {
if (!bridge) return Promise.reject(ERROR_CODES.NO_BRIDGE)

Expand All @@ -78,6 +86,7 @@ const uploadFiles = async ({
type: mimeType,
maxSize,
totalSize,
mediaQuality,
},
timeout: FILE_LOAD_TIMEOUT,
})
Expand Down
6 changes: 6 additions & 0 deletions src/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ export type SubscriptionPayload = {
type: SubscriptionPayloadType
id: string
}

export enum FILE_MEDIA_QUALITY {
LOW = 'low',
MEDIUM = 'medium',
HIGH = 'high',
}