Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qr - data path to vcard #289

Closed
extensionteamhq opened this issue Apr 8, 2024 · 4 comments
Closed

qr - data path to vcard #289

extensionteamhq opened this issue Apr 8, 2024 · 4 comments

Comments

@extensionteamhq
Copy link

It appears that the qr data to encode will not work with a relative path /vcard.vcf and it also doesn't seem to recognize when it is a file to be downloaded.

If I use the relative path /vcard.vcf the result is search "/vcard.vcf".

If I use a full path, https://example.com/vcard.vcf, the result is a link to https://example.com/.

@vnphanquang
Copy link
Owner

vnphanquang commented Apr 9, 2024

Hello @extensionteamhq. A couple of things:

If I use the relative path /vcard.vcf the result is search "/vcard.vcf".

Data is encoded as is, and I believe that is how it should be with any QR. @svelte-put/qr cannot assume any external context, i.e it cannot automatically prepend the current origin, if any, to your relative path, if that is what you mean.


If I use a full path, https://example.com/vcard.vcf, the result is a link to https://example.com/.

Can you provide a reproduction for this? Here is a REPL using https://example.com/ as the data for enconding.

@extensionteamhq
Copy link
Author

Hi @vnphanquang, thanks for the quick reply.

It's not encoding the contents of the file /vcard.vcf but instead encoding the literal string of /vcard.vcf.

The examples I've seen are using a URL (e.g., https://example.org/) and that works fine, or as intended, passing a URL as the string of data to encode.

I would, however, like to encode the contents of the file at /vcard.vcf, which is just a text file—similar to this:

BEGIN:VCARD
VERSION:3.0
REV:2024-04-08T00:00:00Z
PROFILE:VCARD
SOURCE:http://personaldomain.com/vcard.vcf
CLASS:public
FN:Alex Suprun
ORG:Company Name
LOGO;TYPE=PNG:http://workdomain.com/logo.png
ADR;TYPE=WORK;TYPE=PREF:Company Name;Ste 100;7900 4th St N;St. Petersburg;FL;33702;USA
URL;TYPE=WORK;TYPE=PREF:https://workdomain.com/
TEL;TYPE=WORK;TYPE=VOICE:+1 (727) 555-0000
EMAIL;TYPE=INTERNET;TYPE=WORK;TYPE=PREF:hello@workdomain.com
TITLE:Avatar
ROLE:Member
N:Suprun;Alex;;;
NICKNAME:Spuns
PHOTO;TYPE=PNG;VALUE=URI:http://personaldomain.com/photo.jpg
ADR;TYPE=HOME:;;1234 Main St N;St. Petersburg;FL;33701;USA
TEL;TYPE=CELL;TYPE=VOICE;TYPE=PREF:+1 (727) 222-4444
TEL;TYPE=OTHER;TYPE=VOICE:+1 (727) 321-9876
EMAIL;TYPE=INTERNET;TYPE=HOME:alexsuprun@personaldomain.com
EMAIL;TYPE=INTERNET;TYPE=OTHER:alexsuprun@otherdomain.com
URL;TYPE=HOME:https://personaldomain.com/
URL;TYPE=OTHER:https://otherdomain.com/
TZ:-0500
X-SOCIALPROFILE;TYPE=Facebook:alexsuprun
X-SOCIALPROFILE;TYPE=Twitter:alexsuprun
X-SOCIALPROFILE;TYPE=LinkedIn:alexsuprun
X-SOCIALPROFILE;TYPE=Instagram:alexsuprun
X-SOCIALPROFILE;TYPE=YouTube:alexsuprun
X-SOCIALPROFILE;TYPE=TikTok:alexsuprun
CATEGORIES:avatar,persona,mockup
NOTE:I'm Alex Suprun, a connoisseur of the subtle art of connection. I weave the mundane into the magical with ease, turning pet whispers into the talk of the town. My knack for reading a room's vibe rivals ancient oracles, and my adventures often involve epic quests for legendary late-night snacks.
END:VCARD

I hope that examples my scenario better.

@vnphanquang
Copy link
Owner

Hello @extensionteamhq, thanks for the clarification. Just so we are on the same page, you want to encode the content of your vcard.vcf file in the QR code yes?

As I've mentioned, whatever passed to the data option is the QR-encoded data; @svelte-put does not automatically fetch the file for you. In other words, if you want to encode the file content, you need to pass that content as the data option. There are multiple ways to do this:

  • if your file is completely static, just import using Vite '?raw' syntax (assume you are using Svelte with Vite).
  • if your file is dynamic or has to live in the /static directory, do a fetch and pass the response text as data.

I've put together an example here showing both of the methods above. Please take a look and let me know if that's what you are looking for.

Important

The content of your vcard.vcf is quite a lot in size. Notice, in the given example, I had to change the error correction level to either S or M to be able to fit the data in the generated QR. You can check out the QR capacity and play around more using this demo site.

@extensionteamhq
Copy link
Author

Hi @vnphanquang, Thanks again for the quick reply. What you provided was very helpful and informative. Also, thank you for building out the two examples; they helped me understand what was being said.

Repository owner locked and limited conversation to collaborators Apr 11, 2024
@vnphanquang vnphanquang converted this issue into discussion #291 Apr 11, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants