jpsider / RestPS

Simple ReST Framework for Powershell
MIT License
112 stars 30 forks source link

Support for (binary) file uploads #85

Open Surowa opened 7 months ago

Surowa commented 7 months ago

This adds a way to upload files. The way I currently designed it, is by having an additional entry in the json config file that allows a file destination path set server-side. Having it set client-side with parameters would be a security issue, imo. After the file has been uploaded to the server, the normal scripts that get invoked can be used to actually do something else with the file, such as adding it to some external database, or moving it elsewhere. Let me know if you like the current design, or if you prefer something else.

Example client request: $uri = 'http://localhost:8081/files' $filePath = 'c:/temp/testfile.json' $upload= Invoke-RestMethod -Uri $uri -Method Post -InFile $filePath -ContentType 'multipart/form-data'

jpsider commented 7 months ago

I hope to review this within the next week.

jpsider commented 7 months ago

I'm wondering if these changes belong in Invoke-RequestRouter.ps1?

Surowa commented 7 months ago

Could be, is that the best place for handling this type of request post-processing?

jpsider commented 7 months ago

Yeah, I think so that file is where all important things kinda happen now.