/// <summary> /// Wrapper to send file message E2E <see cref="Threema.MsgApi.E2EHelper.SendFileMessage"/> /// </summary> /// <param name="to">Recipient id</param> /// <param name="from">Sender id</param> /// <param name="secret">Sender sercret</param> /// <param name="privateKey">Sender private key</param> /// <param name="file">File path to file</param> /// <param name="thumbnail">File path to thumbnail</param> /// <param name="apiUrl">Optional api url</param> /// <returns>Message id</returns> public string SendFileMessage(string to, string from, string secret, string privateKey, string file, string thumbnail = null, string apiUrl = APIConnector.DEFAULTAPIURL) { byte[] privateKeyBytes = GetKey(privateKey, Key.KeyType.PRIVATE); FileInfo fileInfo = file != null ? new FileInfo(file) : null; FileInfo thumbnailInfo = thumbnail != null ? new FileInfo(thumbnail) : null; E2EHelper e2EHelper = new E2EHelper(this.CreateConnector(from, secret, apiUrl), privateKeyBytes); return(e2EHelper.SendFileMessage(to, fileInfo, thumbnailInfo)); }
protected override void Execute() { string to = this.threemaId.Value; string from = this.fromField.Value; string secret = this.secretField.Value; byte[] privateKey = this.privateKeyField.GetValue(); FileInfo file = this.fileField.GetValue(); FileInfo thumbnail = this.thumbnailField.GetValue(); E2EHelper e2EHelper = new E2EHelper(this.CreateConnector(from, secret), privateKey); string messageId = e2EHelper.SendFileMessage(to, file, thumbnail); System.Console.WriteLine("MessageId: " + messageId); }