mirror of
https://github.com/strapi/strapi.git
synced 2025-11-10 23:29:33 +00:00
Merge pull request #16467 from strapi/fix/provider-s3-video-uploads
This commit is contained in:
commit
cd4c3298d4
@ -27,7 +27,7 @@ interface File {
|
|||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
require('aws-sdk/lib/maintenance_mode_message').suppress = true;
|
require('aws-sdk/lib/maintenance_mode_message').suppress = true;
|
||||||
|
|
||||||
function assertUrlProtocol(url: string) {
|
function hasUrlProtocol(url: string) {
|
||||||
// Regex to test protocol like "http://", "https://"
|
// Regex to test protocol like "http://", "https://"
|
||||||
return /^\w*:\/\//.test(url);
|
return /^\w*:\/\//.test(url);
|
||||||
}
|
}
|
||||||
@ -93,11 +93,13 @@ export = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set the bucket file url
|
// set the bucket file url
|
||||||
if (assertUrlProtocol(data.Location)) {
|
if (baseUrl) {
|
||||||
file.url = baseUrl ? `${baseUrl}/${fileKey}` : data.Location;
|
// Construct the url with the baseUrl
|
||||||
|
file.url = `${baseUrl}/${fileKey}`;
|
||||||
} else {
|
} else {
|
||||||
// Default protocol to https protocol
|
// Add the protocol if it is missing
|
||||||
file.url = `https://${data.Location}`;
|
// Some providers like DigitalOcean Spaces return the url without the protocol
|
||||||
|
file.url = hasUrlProtocol(data.Location) ? data.Location : `https://${data.Location}`;
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user