How to properly encode a vCard using JSON to Binary converter

Describe the issue/error/question

Hello community! I’ve successfully built a workflow that takes a vCard stored as a JSON object, coverts it to binary and uploads to an AWS S3 bucket. I intend to share the vCard (vcf format) to a group chat via a Telegram message.

My issue, is that the VCF file is not readable when downloaded to mobile devices. When I open it in a text editor, I can see that it has quote marks at the beginning and end, and many ‘\n’ newline characters. I assume that this is an encoding issue but this is openly outside my comfort/skill level!

Could anyone here help to point me in the right direction?

Here is what the vCard looks like before and after the conversion:

Before:

BEGIN:VCARD 
VERSION:3.0 
PRODID:-//Apple Inc.//iPhone OS 15.1.1//EN 
N:XXXXX;Sebastian;;; 
FN:Sebastian XXXXX 
EMAIL;type=INTERNET;type=pref:[email protected] 
item1.TEL;type=pref:+1 (413) 801-XXXX 
item1.X-ABLabel:USA 
TEL;type=HOME;type=VOICE:+1 (872) XXXXX 
TEL;type=CELL;type=VOICE:07 XXXXX 
item2.TEL:+252612XXXXX 
item2.X-ABLabel:Somalia 
TEL:+254757750952 
X-SOCIALPROFILE;type=facebook:x-apple:sebastian.XXXXX 
X-SOCIALPROFILE;type=twitter:x-apple:XXXX 
END:VCARD

After:

"BEGIN:VCARD \nVERSION:3.0 \nPRODID:-//Apple Inc.//iPhone OS 15.1.1//EN \nN:XXXXX;Sebastian;;; \nFN:Sebastian XXXXX \nEMAIL;type=INTERNET;type=pref:[email protected] \nitem1.TEL;type=pref:+1 (413) 801-XXXX \nitem1.X-ABLabel:USA \nTEL;type=HOME;type=VOICE:+1 (872) 252XXXX \nTEL;type=CELL;type=VOICE:07 XXXX \nitem2.TEL:+252612XXXXX \nitem2.X-ABLabel:Somalia \nTEL:+2547577XXXXX \nX-SOCIALPROFILE;type=facebook:x-apple:sebastian.XXXXX \nX-SOCIALPROFILE;type=twitter:x-apple:XXXX \nEND:VCARD \n"

What is the error message (if any)?

Please share the workflow

{
  "nodes": [
    {
      "parameters": {
        "mode": "jsonToBinary",
        "convertAllData": false,
        "sourceKey": "=fields.VCard",
        "destinationKey": "=binaryVcard",
        "options": {
          "mimeType": "Content-Type: text/vcard"
        }
      },
      "name": "Move Binary Data",
      "type": "n8n-nodes-base.moveBinaryData",
      "typeVersion": 1,
      "position": [
        2820,
        2040
      ]
    },
    {
      "parameters": {
        "operation": "upload",
        "bucketName": "n8n-vcard",
        "fileName": "={{encodeURI($node[\"Add to Airtable1\"].json[\"fields\"][\"POC Name\"]+'_'+$node[\"Add to Airtable1\"].json[\"id\"])}}.vcf",
        "binaryPropertyName": "binaryVcard",
        "additionalFields": {}
      },
      "name": "AWS S3",
      "type": "n8n-nodes-base.awsS3",
      "typeVersion": 1,
      "position": [
        2980,
        2040
      ],
      "credentials": {
        "aws": {
          "id": "7",
          "name": "AWS account"
        }
      }
    }
  ],
  "connections": {
    "Move Binary Data": {
      "main": [
        [
          {
            "node": "AWS S3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database you’re using (default: SQLite):
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]:

Hi @Felix_is_stuck, have you tried enabling the Use Raw Data option of the Move Binary Data node? I reckon it might solve the problem you are seeing:

image

Yes - that’s it! Thank you once again @MutedJam :slight_smile:

1 Like