如何在服务器端解码多部分请求

时间:2018-08-11 07:34:19

标签: dart

Dart版本:Dart VM版本:“ macos_x64”上的2.0.0-dev.68.0

我正试图通过Multipart表单请求来处理流文件。

问题1:

client.dart文件看起来正确吗?我还不太确定,但是我可以执行代码并获得“已上传”响应。但是脚本在消息后一直挂着。

问题2:

如何在服务器端解码数据?我尝试查找示例,但发现的示例已过时。我尝试断点调试来检查server.dart中的req变量,但找不到数据。

pubspec.yaml

var map;
var markers = [];

/* KAART FILTER */

// Klik op de input opvangen
jQuery(function () {
    jQuery('input[name=filter]').change(function () {
      var filterklikid = jQuery(this).attr('id');
      MarkersFilter(filterklikid);
  });
});

// Marker tonen of verbergen aan de hand van de staat van de input
function MarkersFilter(category){
   if (document.getElementById(category).checked===false) { // Verberg de marker
      for (var i=0;i<markers.length;i++) {
         if (markers[i].properties==category)  {
            markers[i].setVisible(false);
         }
      }
   } else { // Toon de marker
      for (var i=0;i<markers.length;i++) {
         if (markers[i].properties==category)  {
            markers[i].setVisible(true);
         }
      }
   }
}

/* EINDE KAART FILTER */

/* ICONEN VOOR VERSCHILLENDE TYPES */

var iconBase = '/mapshapes/';
        var icons = {
          scholen: {
            icon :{
              url: iconBase + 'scholen_maps.svg',
              scaledSize: new google.maps.Size(35, 35),
              origin: new google.maps.Point(0,0),
              anchor: new google.maps.Point(0, 0)
            }
          },
          handel: {
            icon: {
              url: iconBase + 'handel_maps.svg',
              scaledSize: new google.maps.Size(35, 35),
              origin: new google.maps.Point(0,0),
              anchor: new google.maps.Point(0, 0)
            }
          },
          cultuur: {
            icon:{
              url: iconBase + 'cultuur_maps.svg',
              scaledSize: new google.maps.Size(35, 35),
              origin: new google.maps.Point(0,0),
              anchor: new google.maps.Point(0, 0)
            }
          },
          gezondheid: {
            icon:{
              url : iconBase + 'gezondheid_maps.svg',
              scaledSize: new google.maps.Size(35, 35),
              origin: new google.maps.Point(0,0),
              anchor: new google.maps.Point(0, 0)
            }
          },
          sport: {
            icon:{
              url: iconBase + 'sport_maps.svg',
              scaledSize: new google.maps.Size(35, 35),
              origin: new google.maps.Point(0,0),
              anchor: new google.maps.Point(0, 0)
            }
          },
          veiligheid: {
            icon:{
              url: iconBase + 'veiligheid_maps.svg',
              scaledSize: new google.maps.Size(35, 35),
              origin: new google.maps.Point(0,0),
              anchor: new google.maps.Point(0, 0)
            }
          },
          horeca: {
            icon:{
              url: iconBase + 'horeca_maps.svg',
              scaledSize: new google.maps.Size(35, 35),
              origin: new google.maps.Point(0,0),
              anchor: new google.maps.Point(0, 0)
            }
          },
          openbaarvervoer: {
            icon:{
              url: iconBase + 'openbaarvervoer_maps.svg',
              scaledSize: new google.maps.Size(35, 35),
              origin: new google.maps.Point(0,0),
              anchor: new google.maps.Point(0, 0)
            }
          },
          libris: {
            icon:{
              url: iconBase + 'libris.png',
              scaledSize: new google.maps.Size(70, 70),
              origin: new google.maps.Point(0,0),
              anchor: new google.maps.Point(0, 0)
            }
          }
        };

function loadMarkers(map) {

  var infoWindow = new google.maps.InfoWindow();
  geojson_url = '/project.geojson';

  jQuery.getJSON(geojson_url, function(result) {
      data = result['locations'];
      jQuery.each(data, function(key, val) {
        var point = new google.maps.LatLng(parseFloat(val['geometry']['coordinates'][0]), parseFloat(val['geometry']['coordinates'][1]));
        var titleText = val['properties']['name'];    
        var address = val['geometry']['address'];
        var marker = new google.maps.Marker({
           position: point,
           title: titleText,
           icon: icons[val['type']].icon,
           map: map,
           properties: val['type']
        });
        mc.addMarkers(markers);
        var markerInfo = "<div><h3>" + titleText + "</h3> " + address + "</div>";
        marker.addListener('click', function() {
          infoWindow.close();
          infoWindow.setContent(markerInfo);
          infoWindow.open(map, marker);
        });
        markers.push(marker);
      });
      var Marker = new MarkerCluster(map, markers, {imagePath: 'http://localhost/libris/mapshapes/'});
  });
}

/* MAP AANMAKEN */
function initMap() {
    map_options = {
      zoom: 16,
      center: {lat: 50.808757, lng: 4.314472},
      styles: [
    {
        "featureType": "administrative",
        "elementType": "labels.text.fill",
        "stylers": [
            {
                "color": "#444444"
            }
        ]
    },
    {
        "featureType": "landscape",
        "elementType": "all",
        "stylers": [
            {
                "color": "#f2f2f2"
            }
        ]
    },
    {
        "featureType": "poi",
        "elementType": "all",
        "stylers": [
            {
                "visibility": "off"
            }
        ]
    },
    {
        "featureType": "road",
        "elementType": "all",
        "stylers": [
            {
                "saturation": -100
            },
            {
                "lightness": 45
            }
        ]
    },
    {
        "featureType": "road.highway",
        "elementType": "all",
        "stylers": [
            {
                "visibility": "simplified"
            }
        ]
    },
    {
        "featureType": "road.arterial",
        "elementType": "labels.icon",
        "stylers": [
            {
                "visibility": "off"
            }
        ]
    },
    {
        "featureType": "transit",
        "elementType": "all",
        "stylers": [
            {
                "visibility": "off"
            }
        ]
    },
    {
        "featureType": "water",
        "elementType": "all",
        "stylers": [
            {
                "color": "#46bcec"
            },
            {
                "visibility": "on"
            }
        ]
    }
]
    }


    map_document = document.getElementById('projectmap');
    map = new google.maps.Map(map_document,map_options);
    loadMarkers(map);
}

google.maps.event.addDomListener(window, 'load', initMap);

bin / client.dart

browser = Watir::Browser.new

loginpage = browser.goto('https://www.login-page.com')

bin / server.dart

name: fromscratch
dependencies:
 http: ^0.11.3+17

0 个答案:

没有答案