Git Product home page Git Product logo

birdmessenger's People

Contributors

alexandru-bagu avatar bluetianx avatar dependabot[bot] avatar ilepekhov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

birdmessenger's Issues

HttpHeaders not passed to all requests

When calling TusPatchAsync() method there are multiple http requests underneath. When passing TusPatchRequestOption with custom HttpHeaders this headers are not passed to all of this http requests. The TusHeadAsync() method is called without custom headers:

var tusHeadResp =await httpClient.TusHeadAsync(tusHeadRequestOption, ct);

and here:
var tusHeadResp = await httpClient.TusHeadAsync(tusHeadRequestOption, ct);

I believe it is not expected behavior. I am not sure if this is the only place with such problem.

Chunked upload in v3

Hello,
is there also in version 3.x the possibility to disable streaming and upload files with a fixed chunk size (like in version 2)?
If no, is it planned to implement this in the future?

Thank you and best regards,
Jonas

Sample TestDotNetSite Issue

Hi, I want to try sample TestDotNetSite but it didn't have a web page. What do I need to do for the first step?

Support zero length uploads

Currently if UploadLength is set to zero without setting IsUploadDeferLength to true, the library will throw an error that "UploadLength should not be less than zero", so it is not possible to upload empty files without adjusting headers with OnPreSendRequestAsync event.

奇怪的错误creation response statusCode is BadRequest

您好,使用BirdMessenger为我解决了不少问题,非常感谢。
但是最近上传一批文件时全都上传失败,
执行到var fileUrl = await tusClient.Create(fileInfo);
返回creation response statusCode is BadRequest
这批文件都大于70M,使用2.0.1都无法上传。我试了下小文件可以。
1.0.1的BirdMessenger大文件小文件都没问题
百思不得其解,希望您能帮忙,代码如下

     FileInfo fileInfo = new FileInfo(filePath);                      
        var hostUri = new Uri("http://"+ appConfig.AppConfigGet("serverhost") + ":6008/uploads");            
        var tusClient = TusBuild.DefaultTusClientBuild(hostUri)
            .Configure((options, builder) =>
            {
                builder.ConfigureHttpClient((serviceProiver, client) =>
                {                        
                    if (dict != null)
                    {
                        dict.Keys.ForEach(t =>
                        {
                            client.DefaultRequestHeaders.Add(t, dict[t]);
                        });
                    }
                });
            })            
        .Build();

        tusClient.UploadProgress += TusClient_UploadProgress; 
        tusClient.UploadFinish += TusClient_UploadFinish;          

        var fileUrl = await tusClient.Create(fileInfo);
        var uploadResult = await tusClient.Upload(fileUrl, fileInfo, null);

文件上传完成之后,客户端如何得到Http返回值?

我用了你BirdMessager效果很赞。

我有一个疑问,文件上传之后,服务器给文件赋予了一个整数ID,作为标识。
如何才能得到服务器的Http返回值呢?

我现在的做法是,客户端产生一个GUID,放到TUSHeader里面随文件一起传上去,服务器存文件之后,产生文件ID,将GUID和文件ID存入数据库。

然后客户端在文件传输完成事件中,再去用GUID做为参数请求一个新的WebAPI获得文件ID,有没有可能,文件存完之后,服务器返回业务生成的ID值给客户端?

谢谢。

Improve the TusPatchResponse to include the upload result.

Currently its quite difficult to handle a failed upload using TusPatchWithChunkAsync. If the upload fails while uploading a following chunk it returs the response of the previous (succeeded) chunk. If I now check the reponse for succeeded statuscode its not correct. I would need to check the size as well 8as you do it in the OnCompletedAsync callback.
Using the OnCompletedAsync callback to check for a suceeded call is a lot lines of code to write. If you could add a bool property 'UploadSuceeded' to the TusPatchResponse I could check easily for a succeeded call.
So, at the end of the TusPatchWithChunkAsync method just add following line:
tusPatchResponse.UploadSuceeded = (totalSize == uploadedSize);

Than, a caller could just do like that:
var result = await httpClient.TusPatchAsync(tusPatchRequestOption, cancellationToken); return result.UploadSuceeded;

请问如何调用BirdMessenger进行重传?

hi bluetianx

我使用你写的httpclient上传文件到服务器的函数是ok的。

但是,我模拟中断上传,然后重传同一个文件,程序每次都是重新传输传输文件。没有接着上次已经传过的位置进行resume断点续传。

请问有这样功能的demo或者说明吗?需要特别设置什么属性吗?

从BirdMessenger2.2.1升级到BirdMessenger3.1.0程序出现异常

您好!从BirdMessenger2.2.1升级到BirdMessenger3.1.0程序出现异常
image
OriginResponseMessage:
{StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Transfer-Encoding: chunked
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-store, no-cache
Date: Wed, 17 May 2023 09:29:01 GMT
Server: Tengine/2.3.3
Content-Type: text/plain
Expires: -1
}}

Nuget Pakage 3.0 is not 3.0 in github

I installed BirdMessenger by Pakage Manager and my .csproj file is

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="BirdMessenger" Version="3.0.0" />
    <PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
  </ItemGroup>

</Project>

I cant find namespace of TusCreateRequestOption, TusCreateAsync and others !
I think the BirdMessenger in Nuget Pakage is not 3.0.0 but 2.X

流式传输的问题!

升级到2.2.0,启用流式传输。出现异常。
image

客户端:
at System.Net.ConnectStream.InternalWrite(Boolean async, Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
at System.Net.ConnectStream.BeginWrite(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
at System.IO.Stream.<>c.b__53_0(Stream stream, ReadWriteParameters args, AsyncCallback callback, Object state)
at System.Threading.Tasks.TaskFactory1.FromAsyncTrim[TInstance,TArgs](TInstance thisRef, TArgs args, Func5 beginMethod, Func3 endMethod) at System.IO.Stream.BeginEndWriteAsync(Byte[] buffer, Int32 offset, Int32 count) at System.IO.Stream.WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) at BirdMessenger.Internal.ProgressableStreamContent.<SerializeToStreamAsync>d__7.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.<SendAsync>d__2.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.<SendAsync>d__2.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at BirdMessenger.Core.Tus.d__5.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at BirdMessenger.TusClient.<UploadWithStreamingAsync>d__16.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at BirdMessenger.TusClient.d__14.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at BirdMessenger.TusClient.<Upload>d__17.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at FileStoreCore.FileNetClient.Upload.d__64.MoveNext() in E:\home\filestorecore\FileStoreCore.FileNetClient\Upload.cs:line 315

服务端:
Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Request body too large.
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelBadHttpRequestException.Throw(RequestRejectionReason reason)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ContentLengthMessageBody.OnReadStarting()
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.MessageBody.TryStart()
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ContentLengthMessageBody.ReadAsyncInternal(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory`1 destination, CancellationToken cancellationToken)
at tusdotnet.Helpers.ClientDisconnectGuard.ReadStreamAsync(Stream stream, Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
at tusdotnet.Models.ClientDisconnectGuardedReadOnlyStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
at tusdotnet.Stores.TusDiskStore.AppendDataAsync(String fileId, Stream stream, CancellationToken cancellationToken)
at tusdotnet.IntentHandlers.WriteFileHandler.HandleStreamWrite()
at tusdotnet.IntentHandlers.WriteFileHandler.HandlePipelineWrite()
at tusdotnet.IntentHandlers.WriteFileHandler.Invoke()
at tusdotnet.TusProtocolHandlerIntentBased.Invoke(ContextAdapter context)
at tusdotnet.TusCoreMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

建议增加header参数

正在使用本开源库,非常好用,感谢。
我在使用其他平台的sdk时,可以分别自定义Metadata和header。
强烈建议增加自定义header

Upload Result

Hi,

thanks for this library. I consider to integrate it into my project, but I have the following issue:

When I upload something I need the result of the request. I think the Tus protocol does not allow to change the response to a none-204 status code, but I could add a header with information to point me to the created resource.

At the moment the Tus Client only returns bool, so I cannot access the header. It is also cofusing what "bool" actually means in this context.

How to detect server response status code

I would like to detect when server responses with 409 or 404 or other status code and act accordingly. Is it possible to do it with your library? As I can see your library throws HttpRequestException but it does not allow to get status code.

Download Files

Hi,
I'm currently using tusdotnet on my server and now i want to use the BirdMessenger on the client site.
Uploading Files works great but I also need to be able to download files.
Is there any possibility to do that?
Kind regards

How to specificy upload offset for

Hi,

I am trying to implement a client. The client keeps track of the uploaded bytes.
From #52 (comment) I understand that I should be able to provide upload-offset to patch request option to start from a given offset for failed upload attempts. However couldn't find a way to do it.

Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions

While we try to run the code in different Enviroment(Outsystem)
We are Facing this exception during runtime. .Net Version standard 2.2.0.0
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.File name: 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' at BirdMessenger.TusBuild.DefaultTusClientBuild(Action`1 configure) at BirdMessenger.TusBuild.DefaultTusClientBuild(Uri tusHost)

权限验证不可用 Authority Unavailable

方案1: MetaData
权限信息存在MetaData里. 考虑过后发现不可行.
因为TusClient.Upload()方法里 也就是服务端GetFileInfo 和 WriteFile 接口, 客户端根本就没有发送"Upload-Metadata"的header, 所以不可行.

方案2: Cookie
手动设置cookie无效, 因为UseCookie=true,系统会自动设置cookie, 导致手动设置cookie会被忽略 详情请见https://stackoverflow.com/questions/53906224/cant-get-any-cookies-with-c-sharp-httpclient目前没发现本库怎么设置UseCookie属性, 并且也没有发现怎么设置每次不同的Cookie. 所以暂时不可行

方案3: Header
目前没发现怎么设置每次不同的自定义Header, 所以暂时不可行

请问大佬您是如何解决权限验证问题的呢? 是否考虑增加每次设置Header或Cookie呢?

上传1.9G文件报错patch response statusCode is NotFound

今天在正式环境测试发现上传1.9G的文件客户端报错,但文件在tusfiles目录里存在,并且上传文件是完整的,服务端OnFileCompleteAsync日志记录正常结束。900M文件上传成功无报错!
2021-11-13 19:11:30 [13] ERROR FileStoreCore.FileNetClient.Upload BirdMessenger.Infrastructure.TusException: patch response statusCode is NotFound
在 BirdMessenger.Core.Tus.d__3.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 BirdMessenger.TusClient.d__14.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 BirdMessenger.TusClient.d__15.MoveNext()

TusPatchAsync returns empty

Hi,

I am trying to catch the error case when resumed file upload is requested but partial uploaded file is not present on the server. When
var tusPatchResp = await httpClient.TusPatchAsync(TPRO, CancellationToken.None);
is called, it returns empty tusPatchResponse and print following on console
error: Response status code does not indicate success: 404 (Not Found).
I need this status code (404) returned from your function to act on it and believe this is a bug.

My interpretation looking at your code:
in file HttpClientExtension.cs
inside function TusPatchWithStreamingAsync the code is filling tusPatchResponse after the catch block, so it returns and empty value. I think you want a finally block to fill it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.