mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 05:17:28 -08:00
fix: View option for binary-data shouldn't download the file on Chrome/Edge (#4995)
* delete unused code * fix: Do not set the `Content-Disposition` header when viewing binary files * remove the duplicate styles. these already exist in BinaryDataDisplayEmbed.vue
This commit is contained in:
parent
80e07f86ac
commit
e225c3190e
|
@ -1515,7 +1515,9 @@ class App {
|
|||
identifier,
|
||||
);
|
||||
if (mimeType) res.setHeader('Content-Type', mimeType);
|
||||
if (fileName) res.setHeader('Content-Disposition', `attachment; filename="${fileName}"`);
|
||||
if (req.query.mode === 'download' && fileName) {
|
||||
res.setHeader('Content-Disposition', `attachment; filename="${fileName}"`);
|
||||
}
|
||||
res.setHeader('Content-Length', fileSize);
|
||||
res.sendFile(binaryPath);
|
||||
},
|
||||
|
|
|
@ -235,8 +235,7 @@ export interface IRestApi {
|
|||
deleteExecutions(sendData: IExecutionDeleteFilter): Promise<void>;
|
||||
retryExecution(id: string, loadWorkflow?: boolean): Promise<boolean>;
|
||||
getTimezones(): Promise<IDataObject>;
|
||||
getBinaryBufferString(dataPath: string): Promise<string>;
|
||||
getBinaryUrl(dataPath: string): string;
|
||||
getBinaryUrl(dataPath: string, mode: 'view' | 'download'): string;
|
||||
}
|
||||
|
||||
export interface INodeTranslationHeaders {
|
||||
|
|
|
@ -111,19 +111,5 @@ export default mixins(nodeHelpers, restApi).extend({
|
|||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.binary-data {
|
||||
background-color: var(--color-foreground-xlight);
|
||||
|
||||
&.image {
|
||||
max-height: calc(100% - 1em);
|
||||
max-width: calc(100% - 1em);
|
||||
}
|
||||
|
||||
&.other {
|
||||
height: calc(100% - 1em);
|
||||
width: calc(100% - 1em);
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -56,7 +56,7 @@ export default mixins(restApi).extend({
|
|||
}
|
||||
} else {
|
||||
try {
|
||||
const binaryUrl = this.restApi().getBinaryUrl(id);
|
||||
const binaryUrl = this.restApi().getBinaryUrl(id, 'view');
|
||||
if (isJSONData) {
|
||||
this.jsonData = await (await fetch(binaryUrl)).json();
|
||||
} else {
|
||||
|
|
|
@ -1202,7 +1202,7 @@ export default mixins(externalHooks, genericHelpers, nodeHelpers, pinData).exten
|
|||
const { id, data, fileName, fileExtension, mimeType } = this.binaryData[index][key];
|
||||
|
||||
if (id) {
|
||||
const url = this.restApi().getBinaryUrl(id);
|
||||
const url = this.restApi().getBinaryUrl(id, 'download');
|
||||
saveAs(url, [fileName, fileExtension].join('.'));
|
||||
return;
|
||||
} else {
|
||||
|
|
|
@ -201,13 +201,8 @@ export const restApi = Vue.extend({
|
|||
},
|
||||
|
||||
// Binary data
|
||||
getBinaryBufferString: (dataPath: string): Promise<string> => {
|
||||
return self.restApi().makeRestApiRequest('GET', `/data/${dataPath}`);
|
||||
},
|
||||
|
||||
getBinaryUrl: (dataPath: string): string => {
|
||||
return self.rootStore.getRestApiContext.baseUrl + `/data/${dataPath}`;
|
||||
},
|
||||
getBinaryUrl: (dataPath, mode): string =>
|
||||
self.rootStore.getRestApiContext.baseUrl + `/data/${dataPath}?mode=${mode}`,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue