For a file uploaded to Telegram, I have a file_id and I can download it. But when the file is sent originally, there is an audio object available that has more metadata than the file (for example, title, performer, etc.). Is there a way to get this information again by having just the file_id?
You can use sendAudio method to send the audio to a chat and the response will contain all the attached details.
Unfortunately, it is not possible to get such information from the file_id only. No one knew what was contained in the file_id until recently when a couple of individual managed to 'crack' it. You can check what is in a file_id using this. So a file_id is just a representation of the location of a file on the Telegram servers which contains a little bit of information such as data center, location of file, a hashed checksum which further contains original uploader etc.
Related
Can anyone answer a question for me? I want to know if I'm using pinata correctly. I created a small collection (50 images). Of course there are corresponding .json files for the metadata of each image. I uploaded the 50 images to pinata, then wrote a script that updated the .json files, so the metadata points to the ipfs location for each image. I finally uploaded the 50 .json files to pinata as well. Therefore, the images and the corresponding .json files have different CIDs. Is this the correct way to do this. I'm asking because my images are not showing on testnets.opensea.io. My nft contract sets the base uri to the CID of the metadata files (.json files).
What I usually do is upload a folder containing the JSON metadata of the nfts, so that each file is pointing to the same base URI. Then just set your contract to point your nfts to that base URI, and then just add the nft id to the end. If your JSON has the necessary properties, it should show up correctly on opensea. Be sure that each metadata points to its corresponding image.
I'm trying to create a vCard containing the text below:
BEGIN:VCARD
VERSION:3.0
PHOTO;VALUE=uri:https://upload.wikimedia.org/wikipedia/commons/2/25/Intel_logo_%282006-2020%29.jpg
N:Raven;Test;;;
END:VCARD
according to this documentation (
screenshot of the part I'm talking about ) I tried base64 and it's working fine ( Contact app loads the image ) but in the URI situation it's not working ( Contact app does not load the image ),
To avoid making a large file, my goal is to have a url in my vCard.vcf file not a base64, I'm stuck understanding what's wrong with my vCard.
basically what I'm trying to make is a vCard containing a photo that gets fetched by the url given and shows the photo in contact app of whatever OS the user will open it on (Windows/Android/IOS/macOS).
I'm not using base64 because it makes my vCard file so big.
External urls are probably blocked by most programs, same as loading external images are blocked. It's a massive privacy concern.
Maybe hosting it on a service like Google Cloud would help, in that you can edit the CONTENT-TYPE and CACHE meta data attributes? It’s my novice understanding that smartphone OS is particularly wary of “unknown” file properties - probably for good reason.
I need to send txt File using TelegramBot API .
I already tried https://api.telegram.org/botMYT0KEN/sendDocument?chat_id=569502265&document=/Users/users/Desktop/file.txt
and have issue :
{"ok":false,"error_code":400,"description":"Bad Request: wrong remote
file id specified: Wrong string length”}
To complete Donny's answer, I would like to add an example of sending .txt file as a document.
Looks like you're using OS X as an operating system, which has curl utility preinstalled.
Open terminal and make a request like this:
curl -v -F "chat_id=569502265" -F document=#/Users/users/Desktop/file.txt https://api.telegram.org/bot<TOKEN>/sendDocument
From Telegram official documentation
Sending files There are three ways to send files (photos, stickers, audio, media, etc.):
If the file is already stored somewhere on the Telegram servers, you
don't need to reupload it: each file object has a file_id field,
simply pass this file_id as a parameter instead of uploading. There
are no limits for files sent this way. Provide Telegram with an HTTP
URL for the file to be sent. Telegram will download and send the file.
5 MB max size for photos and 20 MB max for other types of content.
Post the file using multipart/form-data in the usual way that files
are uploaded via the browser. 10 MB max size for photos, 50 MB for
other files. Sending by file_id
It is not possible to change the file type when resending by file_id.
I.e. a video can't be sent as a photo, a photo can't be sent as a
document, etc. It is not possible to resend thumbnails. Resending a
photo by file_id will send all of its sizes. file_id is unique for
each individual bot and can't be transferred from one bot to another.
Sending by URL
When sending by URL the target file must have the correct MIME type
(e.g., audio/mpeg for sendAudio, etc.). In sendDocument, sending by
URL will currently only work for gif, pdf and zip files. To use
sendVoice, the file must have the type audio/ogg and be no more than
1MB in size. 1–20MB voice notes will be sent as files. Other
configurations may work but we can't guarantee that they will.
https://core.telegram.org/bots/api
This is what you need from your question:
Post the file using multipart/form-data in the usual way that files
are uploaded via the browser. 10 MB max size for photos, 50 MB for
other files
You have to use the POST method instead GET. For example, I use https://github.com/php-curl-class/php-curl-class
$url = 'https://api.telegram.org/bot'.$botId.'/sendDocument';
$curl = new Curl();
$curl->post($url, [
"chat_id" => $chatId,
"document" => new \CURLFile($file_path)
]);
The PDF files are in my Google Drive. I just got that I can get the number of pages of a PDF sending it as a job to Cloud Print, because Cloud Print will return a JSON object with "numberOfPages" attribute.
Is there any faster and easier way? Thanks in advance.
Well, I actually did like I said.
I take my file, then send it to CloudPrint via its JSON Api. I need to send it to a dummy printer, a printer I registered in CloudPrint but actually is never connected to Internet. Then, I get the number of pages of the PDF file in the value of response's "numberOfPages" attribute. Save this number in some var. Finally, I send a delete petition to JSON Api for my file in the dummy printer, indeed isn't necessary at all.
Thanks!
I'm integrating the Google CardDAV with my webApplication. I have a strange problem sometimes when I make a PUT of a new vCard.
If the vCard contains a UID and the UID is a GUID Google changes the vCard UID with a 16-char UID.
for example: This is my original vCard
BEGIN:VCARD
VERSION:3.0
N:Pinch;David;;;
FN:David Pinch
REV:2013-01-09T09:26:34Z
UID:6c34bedcf256408780d8ffe269ec2b3b
END:VCARD
So I PUT this into Google CardDAV, into the current url:
https://www.google.com/m8/carddav/principals/__uids__/myusername#gmail.com/lists/default/6c34bedcf256408780d8ffe269ec2b3b
The result is ok, and the contact is really created on Google Contacts.
BUT:
if "now" I retrieve the current vCard from the same URL i have the following response.
BEGIN:VCARD
VERSION:3.0
N:Pinch;David;;;
FN:David Pinch
REV:2013-01-09T09:44:25Z
UID:716212e795884e43
END:VCARD
You can see that UID has changed and passed from original
UID:6c34bedcf256408780d8ffe269ec2b3b
To
UID:716212e795884e43
Curiously if I retrieve the card with the following Request
https://www.google.com/m8/carddav/principals/__uids__/myusername#gmail.com/lists/default/716212e795884e43
I have Exactly the same Response, like the vCard references two different Path url.
However when i retrieve the list of the contact from CardDAV, this return the second URL.
If I does not create the vCard with a GUID but with a 16-char UID, Seems that Google accept this, but sometimes it changes However, so I cannot be sure of the uniqueness of the Card.
A workaround seem to be of re-download the vCard after every PUT, but this causes a payload important that I wanted to avoid.
I use the same procecures with iCloud CardDAV and this doesn't happen.
Anyone can help me?
When you PUT a vCard to Google CardDAV it will recreate a new vCard V3.0 and dispose the original data posted including data loss and the UID / URI path changes you describe.
Other then UID change Google CardDAV has other issues
Data loss
Rejection of valid vCards
Slowness (10-20s per write
operation)
More details in the following Google CardDAV stress test article:
https://evertpot.com/google-carddav-issues/
My advise after still seeing these failures in 2018: its better to use Google's Contacts API instead of there CardDAV implementation.