@@ -143,13 +143,28 @@ def handle_exception(e):
143143 return response
144144
145145
146- def generate_native_viewable_and_light_viewable (geode_object , data ):
146+ def generate_native_viewable_and_light_viewable (geode_object , data , original_filename = None ):
147147 generated_id = str (uuid .uuid4 ()).replace ("-" , "" )
148148 DATA_FOLDER_PATH = flask .current_app .config ["DATA_FOLDER_PATH" ]
149149 data_path = os .path .join (DATA_FOLDER_PATH , generated_id )
150150 name = data .name ()
151151 object_type = geode_functions .get_object_type (geode_object )
152152
153+ os .makedirs (data_path , exist_ok = True )
154+
155+ additional_files_copied = []
156+ if original_filename :
157+ original_file_path = geode_functions .upload_file_path (original_filename )
158+ additional = geode_functions .additional_files (geode_object , original_file_path )
159+
160+ import shutil
161+ for additional_file in additional .mandatory_files + additional .optional_files :
162+ if not additional_file .is_missing and geode_functions .file_exists_in_upload (additional_file .filename ):
163+ source_path = geode_functions .upload_file_path (additional_file .filename )
164+ dest_path = os .path .join (data_path , additional_file .filename )
165+ shutil .copy2 (source_path , dest_path )
166+ additional_files_copied .append (additional_file .filename )
167+
153168 saved_native_file_path = geode_functions .save (
154169 geode_object ,
155170 data ,
@@ -167,7 +182,7 @@ def generate_native_viewable_and_light_viewable(geode_object, data):
167182 binary_light_viewable = f .read ()
168183 f .close ()
169184
170- return {
185+ result = {
171186 "name" : name ,
172187 "native_file_name" : os .path .basename (saved_native_file_path [0 ]),
173188 "viewable_file_name" : viewable_file_name ,
@@ -176,3 +191,8 @@ def generate_native_viewable_and_light_viewable(geode_object, data):
176191 "binary_light_viewable" : str (binary_light_viewable , "utf-8" ),
177192 "geode_object" : geode_object ,
178193 }
194+
195+ if additional_files_copied :
196+ result ["additional_files" ] = additional_files_copied
197+
198+ return result
0 commit comments