Java发出POST请求以表达js服务器并下载PDF文件

时间:2019-08-29 10:37:36

标签: java express

我有Express js服务器作为API。我需要向该服务器发送POST请求,并且我的网站需要将PDF文件下载到客户端计算机。

这是我的快递服务器代码:

(new-env) C:\Automation\test-automation\connect>pip install python-snappy
Collecting python-snappy
  Using cached https://files.pythonhosted.org/packages/45/35/65d9f8cc537129894b4b32647d80212d1fa342877581c5b8a69872cea8be/python-snappy-0.5.4.tar.gz
Installing collected packages: python-snappy
  Running setup.py install for python-snappy ... error
    Complete output from command C:\Automation\test-automation\new-env\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\vagrant\\AppData\\Local\\Temp\\
2\\pip-install-17b8xwg1\\python-snappy\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))
" install --record C:\Users\vagrant\AppData\Local\Temp\2\pip-record-vdvhb6a5\install-record.txt --single-version-externally-managed --compile --install-headers C:\Automation\tes
t-automation\new-env\include\site\python3.7\python-snappy:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
    creating build\lib.win32-3.7\snappy
    copying snappy\hadoop_snappy.py -> build\lib.win32-3.7\snappy
    copying snappy\snappy.py -> build\lib.win32-3.7\snappy
    copying snappy\snappy_cffi.py -> build\lib.win32-3.7\snappy
    copying snappy\snappy_cffi_builder.py -> build\lib.win32-3.7\snappy
    copying snappy\snappy_formats.py -> build\lib.win32-3.7\snappy
    copying snappy\__init__.py -> build\lib.win32-3.7\snappy
    copying snappy\__main__.py -> build\lib.win32-3.7\snappy
    running build_ext
    building 'snappy._snappy' extension
    creating build\temp.win32-3.7
    creating build\temp.win32-3.7\Release
    creating build\temp.win32-3.7\Release\snappy
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Automation\test-automation\new-env\include "-IC:\Program Files (x8
6)\Python37-32\include" "-IC:\Program Files (x86)\Python37-32\include" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\
10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows
 Kits\8.1\include\winrt" /EHsc /Tpsnappy/snappymodule.cc /Fobuild\temp.win32-3.7\Release\snappy/snappymodule.obj
    snappymodule.cc
    snappy/snappymodule.cc(31): fatal error C1083: Cannot open include file: 'snappy-c.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2
----------------------------------------
Command "C:\Automation\test-automation\new-env\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\vagrant\\AppData\\Local\\Temp\\2\\pip-install-17b8xwg1\
\python-snappy\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Us
ers\vagrant\AppData\Local\Temp\2\pip-record-vdvhb6a5\install-record.txt --single-version-externally-managed --compile --install-headers C:\Automation\test-automation\new-env\inc
lude\site\python3.7\python-snappy" failed with error code 1 in C:\Users\vagrant\AppData\Local\Temp\2\pip-install-17b8xwg1\python-snappy\

(new-env) C:\Automation\test-automation\connect>

在我的网站上,我有commandButton来调用POST请求的操作; 我做错了什么,我的网站没有下载任何文件?

发出POST请求的方法:

const pdf = await generatePDF(data.originURL, data.url, data.pageOrientation); //pdf generation

// send pdf to client
res.writeHead(200, {
  'Content-Type': 'application/pdf',
  'Content-Disposition': 'attachment; filename=file.pdf',
  'Content-Length': pdf.length
});
res.end(pdf);

0 个答案:

没有答案