extensions/ipynb/src/notebookImagePaste.ts/buildAttachment
function buildAttachment(b64: string, cell: vscode.NotebookCell, filename: string, filetype: string, startingAttachments: any): { metadata: { [key: string]: any }; filename: string } {
	const cellMetadata = { ...cell.metadata };
	let tempFilename = filename + filetype;

	if (!cellMetadata.attachments) {
		cellMetadata['attachments'] = { [tempFilename]: { 'image/png': b64 } };
	} else {
		for (let appendValue = 2; tempFilename in startingAttachments; appendValue++) {
			const objEntries = Object.entries(startingAttachments[tempFilename]);
			if (objEntries.length) { // check that mime:b64 are present
				const [, attachmentb64] = objEntries[0];
				if (attachmentb64 === b64) { // checking if filename can be reused, based on camparison of image data
					break;
				} else {
					tempFilename = filename.concat(`-${appendValue}`) + filetype;
				}
			}
		}
		cellMetadata.attachments[tempFilename] = { 'image/png': b64 };
	}

	return {
		metadata: cellMetadata,
		filename: tempFilename
	};
}