New-UDUpload is not working for .zip files

@adam

I was testing the following example to upload a .zip file and found that the file is uploaded as 0kb and saved on desired location.
the upload works fine for other file types e.g text , image

New-UDUpload -Text 'Upload Image' -OnUpload {
    $Data = $Body | ConvertFrom-Json 
    $bytes = [System.Convert]::FromBase64String($Data.Data)
    [System.IO.File]::WriteAllBytes("$env:temp\$($Data.Name)", $bytes)
}

is there a specific instructions on how to upload zip files kindly provide an example.

Thank you.

Product: PowerShell Universal
Version: 1.5.15

How large is the zip file?

600Mb and could be above 1GB

I think we’re going to have to increase the PSU request size limit. It’s set to default right now and that looks like it’s ~30mb.

i have tried to update web.config as per your example and that makes PSU to crash and could not open the admin page until i reversed the changes

`<` `security` `>`

`        ` `<` `requestFiltering` `>`

`          ` `<!-- This will handle requests up to 5000MB -->`

`          ` `<` `requestLimits` `maxAllowedContentLength` `=` `"52428800"` `/>`

`        ` `</` `requestFiltering` `>`

`      ` `</` `security` `>`

I was just able to use the code below with no issue:

New-UDDashboard -Title "Hello, World!" -Content {
    New-UDForm -Content {
        New-UDUpload -Text 'Upload Image' -OnUpload {
            $Data = $Body | ConvertFrom-Json 
            $Temp = 'C:\Temp'
            $DestinationPath = "$Temp\$($Data.Name)"
            $bytes = [System.Convert]::FromBase64String($Data.Data)
            [System.IO.File]::WriteAllBytes("$Temp\$($Data.Name)", $bytes)
        }
    } -OnSubmit {
        Show-UDToast $Body 
    }
}

But, I actually did hit that same wall at around 30mb. (I started this before Adam’s initial reply)

I also tried adding the security _ RequestFiltering section to web.config. It didn’t crash PSU, but it did not seem to allow larger uploads either - I can test more later.

@rbleattler

i figured out the crashing issue, its because you have to use correct bytes value but the issue still the same after setting up the following in web.config

<security>
        <requestFiltering>
          <!-- This will handle requests up to 2000MB -->
          <requestLimits maxAllowedContentLength="2097152000" />
        </requestFiltering>
      </security>

still the zip file uploaded as 0kb , a smaller size than 30mb uploaded fine but am trying with 600mb no success.

web.config is only used then hosted in IIS.
im pretty sure PU use Kestrel?
so I guess @adam need to support setting that somewhere.
the link also say that:

  • Hosted on IIS (with Kestrel or without Kestrel)
    • Web.config
  • Hosted on Kestrel (as standalone or with Ngnix and Apache server)
    • global
    • builder
    • middleware

Am hosting in IIS

1 Like

I’m thinking of adding a way to customize these kinds of settings via PS so I don’t need to add an option for every possible setting for ASP.NET Core.

But yeah, we might need to get something in there to allow for adjusting that.

1 Like

how do you run Powershell universal in IIS? I dont see how? :slight_smile:

https://docs.powershelluniversal.com/config/hosting/hosting-iis

1 Like

@adam

it will be good if we have these settings in the appsettings.json if possible also this component will be nice if it has the multi upload files feature rather than a single file.
but anyway any soon solution will be much appreciated

someone could make a new component :slight_smile: Uploading Large Files as Chunks Using ReactJS & .Net Core | by Mehmet Yener YILMAZ | The Startup | Medium

one could argu that this is the correct way :slight_smile:

1 Like

1 Like

please check that the module is not locked:
Uploading Large Files to IIS / NET. Core / ASP.NET (webdavsystem.com)

@McAndersDK
based on your link this module limit is 2GB so i dont think this module has anything to do with ~30+ MB file size unless am missing something here.

1 Like