File tree 1 file changed +23
-13
lines changed
1 file changed +23
-13
lines changed Original file line number Diff line number Diff line change @@ -126,21 +126,31 @@ export function listObjectsInS3ForUser(req, res) {
126
126
. on ( 'end' , ( ) => {
127
127
const projectAssets = [ ] ;
128
128
getProjectsForUserId ( userId ) . then ( ( projects ) => {
129
- projects . forEach ( ( project ) => {
130
- project . files . forEach ( ( file ) => {
131
- if ( ! file . url ) return ;
132
-
133
- const foundAsset = assets . find ( asset => file . url . includes ( asset . key ) ) ;
134
- if ( ! foundAsset ) return ;
135
- projectAssets . push ( {
136
- name : file . name ,
137
- sketchName : project . name ,
138
- sketchId : project . id ,
139
- url : file . url ,
140
- key : foundAsset . key ,
141
- size : foundAsset . size
129
+ assets . forEach ( ( asset ) => {
130
+ const name = asset . key . split ( '/' ) . pop ( ) ;
131
+ const foundAsset = {
132
+ key : asset . key ,
133
+ name,
134
+ size : asset . size ,
135
+ url : `${ process . env . S3_BUCKET_URL_BASE } ${ asset . key } `
136
+ } ;
137
+ projects . some ( ( project ) => {
138
+ let found = false ;
139
+ project . files . some ( ( file ) => {
140
+ if ( ! file . url ) return false ;
141
+ if ( file . url . includes ( asset . key ) ) {
142
+ found = true ;
143
+ foundAsset . name = file . name ;
144
+ foundAsset . sketchName = project . name ;
145
+ foundAsset . sketchId = project . id ;
146
+ foundAsset . url = file . url ;
147
+ return true ;
148
+ }
149
+ return false ;
142
150
} ) ;
151
+ return found ;
143
152
} ) ;
153
+ projectAssets . push ( foundAsset ) ;
144
154
} ) ;
145
155
res . json ( { assets : projectAssets } ) ;
146
156
} ) ;
You can’t perform that action at this time.
0 commit comments