Upload Map Attachments - Fluid Topics - 3.8

Integrate Fluid Topics API

Product
Fluid Topics
FT_Version
3.8
Category
Technical Notes

The Add/Update map attachments web service adds (if new) or updates (if existing) attachments to publications based on a metadata selection:

/api/admin/khub/maps/attachments?metadata1=value1&...&metadataN=valueN
The following lines show an example of the Add/Update map attachments web service implementation in Python. The file my_image.png is attached to the map having my_map as the origin ID.
  import json
  import requests
          
  # order for my_image.png
  my_image_order = {
      'id': 'my_image',
      'filename': 'my_image.png',
      'displayName': 'My Image'
      }
            
  # Content of my_image.png file
  with open('my_image.png', 'rb') as f:
      my_image_content = f.read()
            
  # order.json part
      order = {
          "attachments": [my_image_order]
              }
            
  # All the parts : order.json and my_image.png
  parts = {
      'order.json': (
          'order.json', 
          json.dumps(order), 
          'application/json'
          ),
      my_image_order['filename']: (
          my_image_order['filename'], 
          my_image_content, 
          'image/png'
          )
      }
            
  # Send
  response = requests.put('https://demo/api/admin/khub/maps/attachments?ft:originId=my_map', files=parts)
            
  print(response.status_code)
  print(response.text)