/// <summary> /// Retrieve a specific file url of a specific safebox associated to the current user's account. /// </summary> /// <param name="safebox">A Safebox object</param> /// <param name="attachment">An Attachment object</param> /// <param name="cancellationToken"></param> /// <returns>The file url</returns> public async Task <string> FileUrlAsync(Helpers.Safebox safebox, Helpers.Attachment attachment, CancellationToken cancellationToken = default(CancellationToken)) { if (safebox.Guid == null) { throw new Exceptions.SendSecureException("Safebox Guid cannot be null"); } if (attachment.Guid == null) { throw new Exceptions.SendSecureException("Document Guid cannot be null"); } string jsonResponse = await JsonClient.GetFileUrlAsync(safebox.Guid, attachment.Guid, safebox.UserEmail, cancellationToken); var response = JObject.Parse(jsonResponse); return(response["url"].Value <string>()); }
public async Task <Helpers.Attachment> UploadAttachmentAsync(Helpers.Safebox safebox, Helpers.Attachment attachment, CancellationToken cancellationToken = default(CancellationToken)) { string jsonResponse = await JsonClient.UploadFileAsync(new Uri(safebox.UploadUrl), attachment.Stream, attachment.ContentType, attachment.FileName, attachment.Size, cancellationToken); var response = JsonConvert.DeserializeObject <JsonObjects.UploadFileResponseSuccess>(jsonResponse); attachment.Guid = response.temporary_document.document_guid; return(attachment); }