test-upload.ps1 890 B

1234567891011121314151617181920212223242526
  1. # 测试现有SHP文件解析
  2. $shpPath = "d:\Web\PlatformModel\ruoyi-admin\uploads\models\geojson\803381497aa04afe943bb0a04a6ac30c\流域.shp"
  3. $url = "http://localhost:8448/cesium/geojson/upload"
  4. # 读取SHP文件
  5. $shpFileBytes = [System.IO.File]::ReadAllBytes($shpPath)
  6. $shpFileName = [System.IO.Path]::GetFileName($shpPath)
  7. # 尝试调用上传接口
  8. $boundary = [System.Guid]::NewGuid().ToString()
  9. $body = @"
  10. --$boundary
  11. Content-Disposition: form-data; name="file"; filename="$shpFileName"
  12. Content-Type: application/octet-stream
  13. $( [System.Text.Encoding]::UTF8.GetString($shpFileBytes) )
  14. --$boundary--
  15. "@
  16. try {
  17. $response = Invoke-RestMethod -Uri $url -Method Post -Body $body -ContentType "multipart/form-data; boundary=$boundary" -TimeoutSec 60
  18. Write-Host "Response: $($response | ConvertTo-Json)"
  19. } catch {
  20. Write-Host "Error: $_"
  21. Write-Host $_.Exception.Response
  22. }