Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #391

Merged
merged 2 commits into from
Nov 3, 2023
Merged

Dev #391

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions packages/azure_file_storage/api/fileBrowser/azureFileBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,24 @@ module.exports = async (request, response, delegate, next) => {
for await (const blob of blobs) {
const blobName = blob.name;
const blobUrl = `${containerClient.url}/${blobName}`;

// Get the subfolder or file name within the directory
const relativePath = blobName.substring(path.length);

// Check if it's a subfolder or file
const slashIndex = relativePath.indexOf('/');
if (slashIndex === -1) {
// It's a file
files.push({
name: relativePath,
url: blobUrl
});
if (blob.properties.contentLength) {
files.push({
name: relativePath,
url: blobUrl
});
}
} else {
// It's a subfolder
const subfolder = relativePath.substring(0, slashIndex);
subfolders.add(subfolder);
if (subfolder !== '') {
subfolders.add(subfolder);
}
}
}
// Send the response with the uploaded image details
response.status(OK).json({
data: {
folders: Array.from(subfolders),
Expand All @@ -69,7 +68,6 @@ module.exports = async (request, response, delegate, next) => {
});
} catch (error) {
debug('critical', error);
// Return an error response if there was an error uploading the images
response.status(INTERNAL_SERVER_ERROR);
response.json({
error: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const {

let blobServiceClient;
let containerName;
if (getConfig('file_storage') === 'azure') {
if (getConfig('system.file_storage') === 'azure') {
blobServiceClient = BlobServiceClient.fromConnectionString(
getEnv('AZURE_STORAGE_CONNECTION_STRING')
);
Expand All @@ -18,7 +18,7 @@ if (getConfig('file_storage') === 'azure') {

module.exports = async (request, response, delegate, next) => {
// If the file storage is not Azure, call the next middleware function
if (getConfig('file_storage') !== 'azure') {
if (getConfig('system.file_storage') !== 'azure') {
next();
} else {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async function resizeAndUploadImage(
}

module.exports = async function azureGenerateProductImageVariant(data) {
if (getConfig('file_storage') === 'azure') {
if (getConfig('system.file_storage') === 'azure') {
try {
const containerName = getEnv('AZURE_STORAGE_CONTAINER_NAME', 'images');
const originalBlobUrl = data.origin_image;
Expand Down
2 changes: 1 addition & 1 deletion packages/s3_file_storage/api/fileBrowser/awsFileBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const bucketName = getEnv('AWS_BUCKET_NAME');

module.exports = async (request, response, delegate, next) => {
// If the file storage is not S3, skip this middleware
if (getConfig('file_storage') !== 's3') {
if (getConfig('system.file_storage') !== 's3') {
next();
} else {
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/s3_file_storage/api/fileDelete/awsFileDelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const s3Client = new S3Client({ region: getEnv('AWS_REGION') });
const bucketName = getEnv('AWS_BUCKET_NAME');

module.exports = async (request, response, delegate, next) => {
if (getConfig('file_storage') !== 's3') {
if (getConfig('system.file_storage') !== 's3') {
next();
} else {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const bucketName = getEnv('AWS_BUCKET_NAME');

module.exports = async (request, response, delegate, next) => {
// If the file storage is not S3, call the next middleware function
if (getConfig('file_storage') !== 's3') {
if (getConfig('system.file_storage') !== 's3') {
next();
} else {
const imageFiles = request.files;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async function resizeAndUploadImage(
}

module.exports = async function awsGenerateProductImageVariant(data) {
if (getConfig('file_storage') === 's3') {
if (getConfig('system.file_storage') === 's3') {
try {
const s3Client = new S3Client({ region: getEnv('AWS_REGION') });
const originalObjectUrl = data.origin_image;
Expand Down
Loading