mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00: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:
committed by
GitHub
parent
80e07f86ac
commit
e225c3190e
@@ -1515,7 +1515,9 @@ class App {
|
|||||||
identifier,
|
identifier,
|
||||||
);
|
);
|
||||||
if (mimeType) res.setHeader('Content-Type', mimeType);
|
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.setHeader('Content-Length', fileSize);
|
||||||
res.sendFile(binaryPath);
|
res.sendFile(binaryPath);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -235,8 +235,7 @@ export interface IRestApi {
|
|||||||
deleteExecutions(sendData: IExecutionDeleteFilter): Promise<void>;
|
deleteExecutions(sendData: IExecutionDeleteFilter): Promise<void>;
|
||||||
retryExecution(id: string, loadWorkflow?: boolean): Promise<boolean>;
|
retryExecution(id: string, loadWorkflow?: boolean): Promise<boolean>;
|
||||||
getTimezones(): Promise<IDataObject>;
|
getTimezones(): Promise<IDataObject>;
|
||||||
getBinaryBufferString(dataPath: string): Promise<string>;
|
getBinaryUrl(dataPath: string, mode: 'view' | 'download'): string;
|
||||||
getBinaryUrl(dataPath: string): string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface INodeTranslationHeaders {
|
export interface INodeTranslationHeaders {
|
||||||
|
|||||||
@@ -111,19 +111,5 @@ export default mixins(nodeHelpers, restApi).extend({
|
|||||||
height: 100%;
|
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>
|
</style>
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export default mixins(restApi).extend({
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
const binaryUrl = this.restApi().getBinaryUrl(id);
|
const binaryUrl = this.restApi().getBinaryUrl(id, 'view');
|
||||||
if (isJSONData) {
|
if (isJSONData) {
|
||||||
this.jsonData = await (await fetch(binaryUrl)).json();
|
this.jsonData = await (await fetch(binaryUrl)).json();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1202,7 +1202,7 @@ export default mixins(externalHooks, genericHelpers, nodeHelpers, pinData).exten
|
|||||||
const { id, data, fileName, fileExtension, mimeType } = this.binaryData[index][key];
|
const { id, data, fileName, fileExtension, mimeType } = this.binaryData[index][key];
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
const url = this.restApi().getBinaryUrl(id);
|
const url = this.restApi().getBinaryUrl(id, 'download');
|
||||||
saveAs(url, [fileName, fileExtension].join('.'));
|
saveAs(url, [fileName, fileExtension].join('.'));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -201,13 +201,8 @@ export const restApi = Vue.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Binary data
|
// Binary data
|
||||||
getBinaryBufferString: (dataPath: string): Promise<string> => {
|
getBinaryUrl: (dataPath, mode): string =>
|
||||||
return self.restApi().makeRestApiRequest('GET', `/data/${dataPath}`);
|
self.rootStore.getRestApiContext.baseUrl + `/data/${dataPath}?mode=${mode}`,
|
||||||
},
|
|
||||||
|
|
||||||
getBinaryUrl: (dataPath: string): string => {
|
|
||||||
return self.rootStore.getRestApiContext.baseUrl + `/data/${dataPath}`;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user