Base solution for your next web application
Open Closed

Chat downloading/view documents #9039


User avatar
0
bruno93 created

Hello,

I'm trying to figure it out how does upload and preview/download documents(pdf,words, etc.) works. However I'm getting error when trying to see document which I was upload on chat.. Any help?

URL: https://localhost:44301/Chat/GetUploadedObject?fileId=a95f04d6-b0bd-1383-e2f0-39f53ec3d18a&fileName=somePDFNAME.pdf&contentType=application/pdf&enc_auth_token=wNYmO41........................ Error in Mozzila:

Error in Chrome:

Also, are there some good tutorial for using upload/preview files?


11 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @bruno93

    Normally uploaded files are saved to database and retrieved when you click the link. Are you using latest version of AspNet Zero ? I couldn't reproduce this problem on latest version and on our demo http://volosoft.demo.aspnetzero.com/.

  • User Avatar
    0
    bruno93 created

    I am using latest version of AspNet Zero, at least I hope so... I just started with asp net zero few days ago. Is there some link how can I upgrade to latest version?

    I also tried on test version, and I'm not having that problem..

  • User Avatar
    0
    musa.demir created

    Hello @bruno93,

    1- You can download any version you want in https://aspnetzero.com/Download page.

    2- Version number of project is location in footer, You can check that.

    Please check your version and inform us about it. Here are the required informations for us to reproduce the problem.

    • What is your product version?
    • What is your product type (Angular or MVC)?
    • What is product framework type (.net framework or .net core)?
  • User Avatar
    0
    bruno93 created

    Hello @demirmusa, What is your product version? 8.7.0.0 What is your product type (Angular or MVC)? Angular What is product framework type (.net framework or .net core)? .net core

  • User Avatar
    0
    musa.demir created

    I could not reproduce the problem. Can you please send recurring project to [email protected]

  • User Avatar
    0
    bruno93 created

    What do you mean by recurring project? The whole project(backend and frontend) i'm working at?

  • User Avatar
    0
    musa.demir created

    A project that we can produce the same error. Whole ASP.NET Zero project if it is not problem for you. (after you clean nodules etc.)

  • User Avatar
    0
    bruno93 created

    Sure, it is not problem. Give me few minutes and I'll send it.

    EDIT: Sent

  • User Avatar
    0
    musa.demir created

    Hello @bruno93

    The problem is about multitenancy, Multitenancy is disabled in your application.

    ChatControllerBase UploadFile saves files with setting tenant id null

    https://github.com/aspnetzero/aspnet-zero-core/blob/073ce19a29cb6a4645266b7a6889d316b99dfc55/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Core/Controllers/ChatControllerBase.cs#L50-L53

    using (CurrentUnitOfWork.SetTenantId(null))
    {
        await BinaryObjectManager.SaveAsync(fileObject);
    }
    

    But it stores it with default tenant's id in db.

    And then ChatController GetUploadedObject queries it with setting tenant id null again. But this time it realt work with tenant id null and that's why it can not find it. https://github.com/aspnetzero/aspnet-zero-core/blob/073ce19a29cb6a4645266b7a6889d316b99dfc55/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Host/Controllers/ChatController.cs#L21

    using (CurrentUnitOfWork.SetTenantId(null))
    {
        var fileObject = await BinaryObjectManager.GetOrNullAsync(fileId);
        if (fileObject == null)
        {
            return StatusCode((int)HttpStatusCode.NotFound);
        }
    
        return File(fileObject.Bytes, contentType, fileName);
    }
    

    I created an issue abouot it. (https://github.com/aspnetzero/aspnet-zero-core/issues/3305) We will investigate the situation that caused this error. Until that, you can change

    -using (CurrentUnitOfWork.SetTenantId(null))
    +using (CurrentUnitOfWork.SetTenantId(1))
    {
        var fileObject = await BinaryObjectManager.GetOrNullAsync(fileId);
        
    
  • User Avatar
    0
    bruno93 created

    @demirmusa thank you for such quick response.

  • User Avatar
    0
    ismcagdas created
    Support Team