fix(xo-server/rest-api): VDI export via NBD
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
|
||||
> Users must be able to say: “I had this issue, happy to know it's fixed”
|
||||
|
||||
- [REST API] Fix VDI export when NBD is enabled
|
||||
|
||||
### Packages to release
|
||||
|
||||
> When modifying a package, add it here with its release type.
|
||||
@@ -32,6 +34,7 @@
|
||||
- @xen-orchestra/backups minor
|
||||
- @xen-orchestra/xapi major
|
||||
- complex-matcher patch
|
||||
- xo-server patch
|
||||
- xo-web minor
|
||||
|
||||
<!--packages-end-->
|
||||
|
||||
@@ -371,9 +371,18 @@ export default class RestApi {
|
||||
wrap(async (req, res) => {
|
||||
const stream = await req.xapiObject.$exportContent({ format: req.params.format })
|
||||
|
||||
stream.headers['content-disposition'] = 'attachment'
|
||||
res.writeHead(stream.statusCode, stream.statusMessage != null ? stream.statusMessage : '', stream.headers)
|
||||
// stream can be an HTTP response, in this case, extract interesting data
|
||||
const { headers = {}, length, statusCode = 200, statusMessage = 'OK' } = stream
|
||||
|
||||
// Set the correct disposition
|
||||
headers['content-disposition'] = 'attachment'
|
||||
|
||||
// expose the stream length if known
|
||||
if (headers['content-length'] === undefined && length !== undefined) {
|
||||
headers['content-length'] = length
|
||||
}
|
||||
|
||||
res.writeHead(statusCode, statusMessage, headers)
|
||||
await pipeline(stream, res)
|
||||
})
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user