parent
735adcfa05
commit
cdf1585b72
1 changed files with 23 additions and 13 deletions
|
@ -126,21 +126,31 @@ export function listObjectsInS3ForUser(req, res) {
|
||||||
.on('end', () => {
|
.on('end', () => {
|
||||||
const projectAssets = [];
|
const projectAssets = [];
|
||||||
getProjectsForUserId(userId).then((projects) => {
|
getProjectsForUserId(userId).then((projects) => {
|
||||||
projects.forEach((project) => {
|
assets.forEach((asset) => {
|
||||||
project.files.forEach((file) => {
|
const name = asset.key.split('/').pop();
|
||||||
if (!file.url) return;
|
const foundAsset = {
|
||||||
|
key: asset.key,
|
||||||
const foundAsset = assets.find(asset => file.url.includes(asset.key));
|
name,
|
||||||
if (!foundAsset) return;
|
size: asset.size,
|
||||||
projectAssets.push({
|
url: `${process.env.S3_BUCKET_URL_BASE}${asset.key}`
|
||||||
name: file.name,
|
};
|
||||||
sketchName: project.name,
|
projects.some((project) => {
|
||||||
sketchId: project.id,
|
let found = false;
|
||||||
url: file.url,
|
project.files.some((file) => {
|
||||||
key: foundAsset.key,
|
if (!file.url) return false;
|
||||||
size: foundAsset.size
|
if (file.url.includes(asset.key)) {
|
||||||
|
found = true;
|
||||||
|
foundAsset.name = file.name;
|
||||||
|
foundAsset.sketchName = project.name;
|
||||||
|
foundAsset.sketchId = project.id;
|
||||||
|
foundAsset.url = file.url;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
return found;
|
||||||
});
|
});
|
||||||
|
projectAssets.push(foundAsset);
|
||||||
});
|
});
|
||||||
res.json({ assets: projectAssets });
|
res.json({ assets: projectAssets });
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue