Skip to content

Commit 6ea9746

Browse files
author
Fatme
authored
Merge pull request #3948 from NativeScript/fatme/limit-app-size
chore: show warning when files to upload exceed the maximum allowed size of 15MB
2 parents d4eba93 + a9099ea commit 6ea9746

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/services/livesync/playground/preview-sdk-service.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { PubnubKeys } from "./preview-app-constants";
33
const pako = require("pako");
44

55
export class PreviewSdkService implements IPreviewSdkService {
6+
private static MAX_FILES_UPLOAD_BYTE_LENGTH = 30000;
67
private messagingService: MessagingService = null;
78
private instanceId: string = null;
89
public connectedDevices: Device[] = [];
@@ -75,6 +76,11 @@ export class PreviewSdkService implements IPreviewSdkService {
7576
onSendingChange: (sending: boolean) => ({ }),
7677
onBiggerFilesUpload: async (filesContent, callback) => {
7778
const gzippedContent = Buffer.from(pako.gzip(filesContent));
79+
const byteLength = gzippedContent.byteLength;
80+
if (byteLength > PreviewSdkService.MAX_FILES_UPLOAD_BYTE_LENGTH) {
81+
this.$logger.warn("The files to upload exceed the maximum allowed size of 15MB. Your app might not work as expected.");
82+
}
83+
7884
const playgroundUploadResponse = await this.$httpClient.httpRequest({
7985
url: this.$config.UPLOAD_PLAYGROUND_FILES_ENDPOINT,
8086
method: "POST",

0 commit comments

Comments
 (0)