Skip to content
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

fixed the "File located on a different DC" issue #53

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added the message param to the SendUploadedDocument method
  • Loading branch information
SmaGMan committed Nov 2, 2021
commit 155e4a59bd33bf6fe7a1ffbba3bc03f9949d0998
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ TgSharp provides two wrappers for sending photo and document:
await client.SendUploadedDocument(new TLInputPeerUser() { UserId = user.Id },
fileResult,
"application/zip", //mime-type
"kitty", // message text

//document attributes, such as file name
new TLVector<TLAbsDocumentAttribute>());
Expand All @@ -134,6 +135,7 @@ You can see the Full code at [SendPhotoToContactTest](https://github.com/nblockc
To download a file you should call the **GetFile** method:

```csharp
// get documnet
await client.GetFile(new TLInputDocumentFileLocation()
{
AccessHash = document.AccessHash,
Expand All @@ -144,6 +146,18 @@ To download a file you should call the **GetFile** method:

//size of fileChunk you want to retrieve
document.Size);
// get photo
TLPhotoSize photoSize = photo.Sizes.ToList().OfType<TLPhotoSize>().Last();
await client.GetFile(new TLInputPhotoFileLocation()
{
AccessHash = photo.AccessHash,
Id = photo.Id,
FileReference = photo.FileReference,
ThumbSize = photoSize.Type,
},

//size of fileChunk you want to retrieve
photoSize.Size);
```

You can see the Full code at [DownloadFileFromContactTest](https://github.com/nblockchain/TgSharp/blob/master/src/TgSharp.Tests/TgSharpTests.cs#L167)
Expand Down
3 changes: 2 additions & 1 deletion src/TgSharp.Core/TelegramClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ public bool IsUserAuthorized()
}

public async Task<TLAbsUpdates> SendUploadedDocument(
TLAbsInputPeer peer, TLAbsInputFile file, string mimeType, TLVector<TLAbsDocumentAttribute> attributes, CancellationToken token = default(CancellationToken))
TLAbsInputPeer peer, TLAbsInputFile file, string message, string mimeType, TLVector<TLAbsDocumentAttribute> attributes, CancellationToken token = default(CancellationToken))
{
return await SendAuthenticatedRequestAsync<TLAbsUpdates>(new TLRequestSendMedia()
{
Expand All @@ -395,6 +395,7 @@ public async Task<TLAbsUpdates> SendUploadedDocument(
MimeType = mimeType,
Attributes = attributes
},
Message = message,
Peer = peer
}, token)
.ConfigureAwait(false);
Expand Down