How to use the mime/lite.getExtension function in mime

To help you get started, we’ve selected a few mime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github elastic / kibana / x-pack / plugins / canvas / common / lib / dataurl.js View on Github external
const [, mimetype, charset, , encoding] = matches;

  // all types except for svg need to be base64 encoded
  const imageTypeIndex = imageTypes.indexOf(matches[1]);
  if (imageTypeIndex > 0 && encoding !== 'base64') {
    return;
  }

  return {
    mimetype,
    encoding,
    charset: charset && charset.split('=')[1],
    data: !withData ? null : str.split(',')[1],
    isImage: imageTypeIndex >= 0,
    extension: mime.getExtension(mimetype),
  };
}
github elastic / kibana / common / lib / dataurl.js View on Github external
if (!matches) return;

  const [, mimetype, charset, , encoding] = matches;

  // all types except for svg need to be base64 encoded
  const imageTypeIndex = imageTypes.indexOf(matches[1]);
  if (imageTypeIndex > 0 && encoding !== 'base64') return;

  return {
    mimetype,
    encoding,
    charset: charset && charset.split('=')[1],
    data: !withData ? null : str.split(',')[1],
    isImage: imageTypeIndex >= 0,
    extension: mime.getExtension(mimetype),
  };
}
github TediCross / TediCross / src / telegram2discord / middlewares.js View on Github external
// Sticker
		ctx.tediCross.file = {
			type: "sticker",
			id: R.ifElse(
				R.propEq("is_animated", true),
				R.path(["thumb", "file_id"]),
				R.prop("file_id")
			)(message.sticker),
			name: "sticker.webp"
		};
	} else if (!R.isNil(message.video)) {
		// Video
		ctx.tediCross.file = {
			type: "video",
			id: message.video.file_id,
			name: "video" + "." + mime.getExtension(message.video.mime_type),
		};
	} else if (!R.isNil(message.voice)) {
		// Voice
		ctx.tediCross.file = {
			type: "voice",
			id: message.voice.file_id,
			name: "voice" + "." + mime.getExtension(message.voice.mime_type),
		};
	}

	next();
}
github Human-Connection / API / server / hooks / save-remote-images.js View on Github external
hook.data[field] = null;
                return;
                // reject(err);
              }
              // hook.app.debug(`###got answer for: ${hook.data[field]}`);
              try {
                const mimeType = res.headers['content-type'];
                if (mimeType.indexOf('image') !== 0) {
                  hook.app.error('its not an image');
                  loading--;
                  hook.data[field] = null;
                  return;
                  // reject(new Error('its not an image'));
                }

                const ext = mime.getExtension(mimeType);

                imgPath += `.${ext}`;

                fs.writeFileSync(imgPath, body, {
                  encoding: 'binary'
                });

                loading--;

                hook.data[field] = uploadsUrl + imgName + `.${ext}`;

                if (imgCount > 0 && loading <= 0) {
                  hook.app.debug('Download(s) finished', urls);
                  resolve(hook);
                } else if (!imgCount) {
                  resolve(hook);
github galtproject / geesome-node / frontend / src / directives / ContentManifestInfoItem / ContentManifestInfoItem.ts View on Github external
extension() {
      if (!this.manifestObj) {
        return null;
      }
      return this.manifestObj.extension || mime.getExtension(this.manifestObj.mimeType) || '';
    },
    showCloseButton() {
github galtproject / geesome-node / frontend / src / directives / ContentManifestItem / ContentManifestItem.ts View on Github external
extension() {
      if (!this.manifestObj) {
        return null;
      }
      return this.manifestObj.extension || mime.getExtension(this.manifestObj.mimeType) || '';
    },
    type() {