-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Currently when you upload a file via Invoke-Restmethod or Invoke-Webrequest and use the -InFile parameter, it puts a lock on the file, so no other process can read it. It does not set seem to set the FileShare.Read flag
(
Line 1221 in f5a7d79
| SetRequestContent(request, new FileStream(InFile, FileMode.Open)); |
I am trying to parallelize to upload of single files to multiple locations.
Steps to reproduce
Run below command twice at the same time, either in multiple PS hosts, via jobs or runspaces.
Invoke-RestMethod -uri "https://artifactory/artifactory/my-tools/testfile.iso" -Method Put -InFile "C:\temp\testfile.iso" -Credential $creds -ContentType "multipart/form-data"Expected behavior
I would not expect this to error since it is a read operation, I would suggest that the file is opened with FileShare.Read Flag, so you can have multiple processes access the file at the same time.
Actual behavior
When you run the commands simultaneously, you will get an The process cannot access the file 'C:\temp\testfile.iso' because it is being used by another process. error
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.1.0-rc.1
PSEdition Core
GitCommitId 6.1.0-rc.1
OS Microsoft Windows 10.0.17738
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0