<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"> <fx:Script> <![CDATA[ import com.esri.ags.utils.JSONUtil; import mx.controls.Alert; import mx.utils.ObjectUtil; private var fileReference:FileReference; private var timer:Timer; private var baseTimer:int; private function onLoad():void { //Instantiate on loading fileReference = new FileReference(); //create the filter which will be just uploading the txt var myFilter:FileFilter = new FileFilter("Zip", "*.zip"); fileReference.browse([ myFilter ]); fileReference.addEventListener(Event.SELECT, onFileSelect); fileReference.addEventListener(Event.COMPLETE, onFileComplete); fileReference.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, onUploadCompleteData); timer = new Timer(1000); timeElapsed.visible = timeElapsed.includeInLayout = true; timer.addEventListener(TimerEvent.TIMER, updateTimer); } private function onFileSelect(event:Event):void { var fileUploadRequest:URLRequest = new URLRequest("http://server/arcgis/rest/services/ServiceName/GPServer/uploads/upload"); fileUploadRequest.method = URLRequestMethod.POST; var urlVars:URLVariables = new URLVariables(); urlVars.f = "json"; urlVars.description = "this is just a test upload"; fileUploadRequest.data = urlVars; fileReference.upload(fileUploadRequest, "file"); baseTimer = getTimer(); timeElapsed.visible = timeElapsed.includeInLayout = true; timer.start(); } private function onFileComplete(event:Event):void { timer.stop(); timeElapsed.visible = timeElapsed.includeInLayout = false; } private function updateTimer(event:TimerEvent):void { timeElapsed.text = "TimeElapsed: " + new Date(getTimer() - baseTimer).seconds + "secs"; } private function onUploadCompleteData(event:DataEvent):void { var result:Object = JSONUtil.decode(event.data); Alert.show(ObjectUtil.toString(result), "upload completed - " + result.item.itemID); } ]]> </fx:Script> <s:Panel id="myPanel" width="500" height="500"> <s:VGroup> <s:Button click="onLoad()" label="Upload"/> <s:Label id="timeElapsed" includeInLayout="false" visible="false"/> </s:VGroup> </s:Panel> </s:Application>
Is there supposed to be an uploads capability as part of the geoprocessor class? The REST enpoint exposes this functionality, but I can't find this capability within the API. Am I missing something?
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.