diff --git a/packages/core/data-transfer/src/strapi/providers/local-source/assets.ts b/packages/core/data-transfer/src/strapi/providers/local-source/assets.ts index 4c5992fea8..792183f74b 100644 --- a/packages/core/data-transfer/src/strapi/providers/local-source/assets.ts +++ b/packages/core/data-transfer/src/strapi/providers/local-source/assets.ts @@ -1,10 +1,15 @@ import { join } from 'path'; import https from 'https'; +import http from 'http'; import { Duplex, PassThrough, Readable } from 'stream'; import { stat, createReadStream, ReadStream } from 'fs-extra'; import type { IAsset } from '../../../../types'; +const httpMethod = (filepath) => { + return filepath?.startsWith('https') ? https : http; +}; + function getFileStream(filepath: string, isLocal = false): PassThrough | ReadStream { if (isLocal) { return createReadStream(filepath); @@ -12,7 +17,7 @@ function getFileStream(filepath: string, isLocal = false): PassThrough | ReadStr const readableStream = new PassThrough(); - https + httpMethod(filepath) .get(filepath, (res) => { if (res.statusCode !== 200) { readableStream.emit( @@ -36,7 +41,7 @@ function getFileStats(filepath: string, isLocal = false): Promise<{ size: number return stat(filepath); } return new Promise((resolve, reject) => { - https + httpMethod(filepath) .get(filepath, (res) => { if (res.statusCode !== 200) { reject(new Error(`Request failed with status code ${res.statusCode}`));