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