mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 05:29:26 +08:00
fix: unable to access files stored in COS (#6512)
* fix: unable to access files stored in COS * fix: ensureUrlEncoded
This commit is contained in:
parent
2c024cc32e
commit
bd51bd545e
@ -59,7 +59,7 @@ export async function getFileData(ctx: Context) {
|
||||
mimetype: file.mimetype,
|
||||
meta: ctx.request.body,
|
||||
storageId: storage.id,
|
||||
...(storageInstance.getFileData ? storageInstance.getFileData(file) : {}),
|
||||
...StorageType?.['getFileData']?.(file),
|
||||
};
|
||||
|
||||
return data;
|
||||
|
@ -10,7 +10,7 @@
|
||||
import { isURL } from '@nocobase/utils';
|
||||
import { StorageEngine } from 'multer';
|
||||
import urlJoin from 'url-join';
|
||||
import { encodeURL } from '../utils';
|
||||
import { encodeURL, ensureUrlEncoded } from '../utils';
|
||||
|
||||
export interface StorageModel {
|
||||
id?: number;
|
||||
@ -54,7 +54,7 @@ export abstract class StorageType {
|
||||
const keys = [
|
||||
this.storage.baseUrl,
|
||||
file.path && encodeURI(file.path),
|
||||
encodeURIComponent(file.filename),
|
||||
ensureUrlEncoded(file.filename),
|
||||
preview && this.storage.options.thumbnailRule,
|
||||
].filter(Boolean);
|
||||
return urlJoin(keys);
|
||||
|
@ -7,11 +7,13 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { isURL } from '@nocobase/utils';
|
||||
import path from 'path';
|
||||
import urlJoin from 'url-join';
|
||||
import { promisify } from 'util';
|
||||
|
||||
import { AttachmentModel, StorageType } from '.';
|
||||
import { STORAGE_TYPE_TX_COS } from '../../constants';
|
||||
import { getFilename, getFileKey } from '../utils';
|
||||
import { getFileKey, getFilename } from '../utils';
|
||||
|
||||
export default class extends StorageType {
|
||||
static defaults() {
|
||||
|
@ -30,7 +30,7 @@ export function getFileKey(record) {
|
||||
return [record.path.replace(/^\/|\/$/g, ''), record.filename].filter(Boolean).join('/');
|
||||
}
|
||||
|
||||
function ensureUrlEncoded(value) {
|
||||
export function ensureUrlEncoded(value) {
|
||||
try {
|
||||
// 如果解码后与原字符串不同,说明已经被转义过
|
||||
if (decodeURIComponent(value) !== value) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user