| 259 | return input |
| 260 | |
| 261 | def create_input( |
| 262 | self, |
| 263 | project, |
| 264 | request, |
| 265 | filename, |
| 266 | member_created: 'Member' = None |
| 267 | ): |
| 268 | |
| 269 | self.input = Input.new( |
| 270 | project = project, |
| 271 | media_type = None, |
| 272 | job_id = request.form.get('job_id'), |
| 273 | type = request.form.get('source', 'from_resumable'), |
| 274 | directory_id = request.form.get('directory_id'), # Not trusted |
| 275 | video_split_duration = request.form.get('video_split_duration'), |
| 276 | batch_id = request.form.get('input_batch_id'), |
| 277 | member_created_id = member_created.id if member_created else None |
| 278 | ) |
| 279 | if request.form.get('input_batch_id') is not None: |
| 280 | self.extract_instance_list_from_batch(self.input, input_batch_id = request.form.get('input_batch_id'), |
| 281 | file_name = filename) |
| 282 | self.extract_metadata_from_batch(self.input, input_batch_id = request.form.get('input_batch_id'), |
| 283 | file_name = filename) |
| 284 | |
| 285 | self.session.add(self.input) |
| 286 | |
| 287 | self.input = Upload.upload_limits( |
| 288 | input = self.input, |
| 289 | file_size = self.dztotalfilesize) |
| 290 | |
| 291 | self.input.original_filename = secure_filename( |
| 292 | filename) # http://flask.pocoo.org/docs/0.12/patterns/fileuploads/ |
| 293 | self.input.extension = os.path.splitext(self.input.original_filename)[1].lower() |
| 294 | self.input.original_filename = os.path.split(self.input.original_filename)[1] |
| 295 | |
| 296 | # At somepoint should really declare |
| 297 | # From UI here... |
| 298 | self.input.dzuuid = self.dzuuid |
| 299 | self.input.action_flow_id = request.headers.get('flow_id') |
| 300 | |
| 301 | if self.input.action_flow_id: |
| 302 | |
| 303 | if self.input.flow is None: |
| 304 | self.input.status = "failed" |
| 305 | self.input.status_text = "No flow found" |
| 306 | return |
| 307 | |
| 308 | self.input.mode = request.headers.get('mode') |
| 309 | |
| 310 | self.input.media_type = Process_Media.determine_media_type(extension = self.input.extension, |
| 311 | input_type = self.input.type) |
| 312 | |
| 313 | if not self.input.media_type: |
| 314 | self.input.status = "failed" |
| 315 | self.input.status_text = f"Invalid file type: {self.input.extension}" |
| 316 | |
| 317 | # self.input.user = |
| 318 | |