2017-05-27 53 views
0

我知道这是一个非常愚蠢的问题,但它仍然有可能使用标准库和SimpleJSON。我可以只使用SimpleJSON上传并在电报中发送照片吗? C#

+0

是的。一张照片是二进制确保你转换为base 64字符串:Convert.ToBase64String(byte []) – jdweng

+0

这不行,我有一个照片的路径只,如果我使用Convert.ToBase64String,我有一个错误(转换类型从“字符串”到“字节[]”是不可能的)。 –

+0

使用Convert之前,您必须将照片转换为字节[]。 – jdweng

回答

1

是的。你可以看到this document

There are three ways to send files (photos, stickers, audio, media, etc.):

1.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.

2.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.

3.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.

第三种方法是你想要的。

+0

我该怎么做?我无法搜索一个例子。 –

+0

@МаксимЮкифагов您需要搜索上传文件,这是另一个问题 – Sean

相关问题