PR comments
This commit is contained in:
parent
33bc11750d
commit
3f4d3faeb3
|
@ -91,13 +91,13 @@ export const buildAttachmentEndpoints = API => {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download an attachment from a row given its column name.
|
* Download an attachment from a row given its column name.
|
||||||
* @param tableId
|
* @param datasourceId the ID of the datasource to download from
|
||||||
* @param rowId
|
* @param rowId the ID of the row to download from
|
||||||
* @param columnName the attachments to delete
|
* @param columnName the column name to download
|
||||||
*/
|
*/
|
||||||
downloadAttachment: async (tableId, rowId, columnName, options) => {
|
downloadAttachment: async (datasourceId, rowId, columnName, options) => {
|
||||||
return await API.get({
|
return await API.get({
|
||||||
url: `/api/${tableId}/rows/${rowId}/attachment/${columnName}`,
|
url: `/api/${datasourceId}/rows/${rowId}/attachment/${columnName}`,
|
||||||
parseResponse: response => response,
|
parseResponse: response => response,
|
||||||
suppressErrors: options?.suppressErrors,
|
suppressErrors: options?.suppressErrors,
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
const extractFileNameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/
|
||||||
|
|
||||||
export function downloadText(filename, text) {
|
export function downloadText(filename, text) {
|
||||||
if (typeof text === "object") {
|
if (typeof text === "object") {
|
||||||
text = JSON.stringify(text)
|
text = JSON.stringify(text)
|
||||||
|
@ -17,9 +19,7 @@ export async function downloadStream(streamResponse) {
|
||||||
|
|
||||||
const contentDisposition = streamResponse.headers.get("Content-Disposition")
|
const contentDisposition = streamResponse.headers.get("Content-Disposition")
|
||||||
|
|
||||||
const matches = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(
|
const matches = extractFileNameRegex.exec(contentDisposition)
|
||||||
contentDisposition
|
|
||||||
)
|
|
||||||
|
|
||||||
const filename = matches[1].replace(/['"]/g, "")
|
const filename = matches[1].replace(/['"]/g, "")
|
||||||
|
|
||||||
|
@ -49,9 +49,7 @@ export async function downloadFile(url, body) {
|
||||||
} else {
|
} else {
|
||||||
const contentDisposition = response.headers.get("Content-Disposition")
|
const contentDisposition = response.headers.get("Content-Disposition")
|
||||||
|
|
||||||
const matches = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(
|
const matches = extractFileNameRegex.exec(contentDisposition)
|
||||||
contentDisposition
|
|
||||||
)
|
|
||||||
|
|
||||||
const filename = matches[1].replace(/['"]/g, "")
|
const filename = matches[1].replace(/['"]/g, "")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue