Skip to content

Commit fc39950

Browse files
fix: tns preview warns incorrectly for exceeding file size limit
The check in `tns preview` relies on the zipped content instead of checking the actual file content. This way, based on what is the zipped content, we may end up with 30000 bytes length for 15 MB input files or for 100KBs input. The check is not correct, it should rely on the input file size, as when extracted on device, their size is the actual limitation.
1 parent a51122b commit fc39950

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +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;
6+
private static MAX_FILES_UPLOAD_BYTE_LENGTH = 15 * 1024 * 1024; // In MBs
77
private messagingService: MessagingService = null;
88
private instanceId: string = null;
99
public connectedDevices: Device[] = [];
@@ -76,7 +76,8 @@ export class PreviewSdkService implements IPreviewSdkService {
7676
onSendingChange: (sending: boolean) => ({ }),
7777
onBiggerFilesUpload: async (filesContent, callback) => {
7878
const gzippedContent = Buffer.from(pako.gzip(filesContent));
79-
const byteLength = gzippedContent.byteLength;
79+
const byteLength = filesContent.length;
80+
8081
if (byteLength > PreviewSdkService.MAX_FILES_UPLOAD_BYTE_LENGTH) {
8182
this.$logger.warn("The files to upload exceed the maximum allowed size of 15MB. Your app might not work as expected.");
8283
}

0 commit comments

Comments
 (0)