MCPcopy
hub / github.com/WebODM/WebODM / post

Method post

coreplugins/dronedb/api_views.py:329–381  ·  view source on GitHub ↗
(self, request, pk)

Source from the content-addressed store, hash-verified

327
328class ShareTaskView(TaskView):
329 def post(self, request, pk):
330
331 from app.plugins import logger
332
333 task = self.get_and_check_task(request, pk)
334
335 # Get optional tag and datasetName from request
336 tag = request.data.get('tag', None)
337 dataset_name = request.data.get('datasetName', None) or task.name
338
339 # Validate tag format if provided
340 if tag is not None and tag.strip():
341 tag = tag.strip().lower()
342 if not TAG_PATTERN.match(tag):
343 return Response({
344 'error': 'Invalid tag format. Must be "org" or "org/dataset" with lowercase alphanumeric characters and hyphens only.'
345 }, status=status.HTTP_400_BAD_REQUEST)
346
347 # Sanitize dataset_name (remove potentially dangerous characters)
348 if dataset_name:
349 dataset_name = dataset_name.strip()[:255] # Limit length
350
351 status_key = get_status_key(pk)
352
353 datastore = get_current_plugin().get_global_data_store()
354
355 data = {
356 'status': 1, # Running
357 'shareUrl': None,
358 'uploadedFiles': 0,
359 'totalFiles': 0,
360 'uploadedSize': 0,
361 'totalSize': 0,
362 'error': None
363 }
364
365 datastore.set_json(status_key, data)
366
367 settings = get_settings(request)
368
369 available_assets = [task.get_asset_file_or_stream(f) for f in list(set(task.available_assets) & set(DRONEDB_ASSETS))]
370
371 if 'textured_model.zip' in task.available_assets:
372 texture_files = [join(task.assets_path('odm_texturing'), f) for f in listdir(task.assets_path('odm_texturing')) if isfile(join(task.assets_path('odm_texturing'), f))]
373 available_assets.extend(texture_files)
374
375 assets_path = task.assets_path()
376
377 files = [{'path': f, 'name': f[len(assets_path)+1:], 'size': os.path.getsize(f)} for f in available_assets]
378
379 share_to_ddb.delay(pk, settings, files, tag, dataset_name)
380
381 return Response(data, status=status.HTTP_200_OK)
382
383
384@task

Callers 2

loginMethod · 0.45
SelectUrlDialogClass · 0.45

Calls 10

get_current_pluginFunction · 0.90
get_status_keyFunction · 0.85
get_settingsFunction · 0.85
setFunction · 0.85
get_and_check_taskMethod · 0.80
get_global_data_storeMethod · 0.80
set_jsonMethod · 0.80
assets_pathMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected