/// <summary> /// メディアをアップロードする。 /// </summary> /// <param name="attachment"></param> /// <returns>MediaID</returns> public Task <long> Upload(UploadMedia attachment) { using var sourceStream = attachment.GetDataStream(); return(this._account.Api.Media.Upload(sourceStream, attachment.Description, progress: attachment) .ContinueWithRan(m => m.Id)); }
/// <summary> /// メディアをアップロードする。 /// </summary> /// <param name="attachment">メディア情報</param> /// <param name="account">アカウント情報</param> /// <returns>MediaID</returns> public Task <long> Upload(UploadMedia attachment) { var mediaApi = this._account.Api.Media; using var stream = attachment.GetDataStream(); bool isVideoUpload = attachment.MediaType.HasFlag(MediaType.Video); var uploadMediaType = isVideoUpload ? MimeTypes.Video.Mp4 : MimeTypes.OctetStream; var task = isVideoUpload ? mediaApi.ChunkedUpload(stream, uploadMediaType, null, attachment) : mediaApi.Upload(stream, null, attachment); return(task.ContinueWithRan(m => m.MediaId)); }