function detectFileType()

in core/nodejsActionBase/runner.js [228:243]


function detectFileType(base64String) {
    // Decode the base64 string into binary data
    const binaryData = Buffer.from(base64String, 'base64');

    // Examine the first few bytes of the binary data to determine the file type
    const magicNumber = binaryData.slice(0, 4).toString('hex');

    if (magicNumber === '504b0304') {
      return 'zip';
    // GZIP: 1f8b0808 maximum compression level,  1f8b0800 default compression
    } else if (magicNumber === '1f8b0808' || magicNumber === '1f8b0800') {
      return 'tar.gz';
    } else {
        return 'unsupported';
    }
}