Matshopp

Geoprocessing Service Output File scratch directory path to url

Discussion created by Matshopp on Aug 5, 2013
Latest reply on Oct 27, 2017 by mmattaini_geoIT
Hello

I'm making a geoprocessing service that returns a .pdf file

As I saw in some examples I used the scratchFolder :
outputFile = os.path.join(arcpy.env.scratchFolder, myPDFFile)
arcpy.SetParameterAsText(7, outputFile)

Once published on the server, the file is recorded here :
D:\arcgisserver\directories\arcgisjobs\myGeoprocessing\j8ba6feb42bce4586971ad1abc33aac81\scratch\myPDFFILE.pdf

When I use the geoprocessingService it returns an 'url' :

http://myServer:6080/arcgis/rest/dir.../myPDFFILE.pdf

----------------------------------------------------------

Here is my problem :
I'd like to return more than just a file. I'd like to return an object that contains my file directory and other pieces of information.
def packResultsToJson(result):

    # -- result looks like :
    # result={}
    # result['succeed']=True
    # result['url']=myPDFFile
    # result['failedLayers']=failedServices
    # result['error']="NoError"
    # result['timeElapsed'] = str(time.time() - start_time) + " seconds"

    arcpy.SetParameterAsText(7, result)

In this case, my pdf directory is inside an object. Once published on the server, the physical windows path is no longer converted as a server 'url' (so the client receives : 'D:\arcgisserver\directories\arcgisjobs\myGeoprocessing\j8ba6feb42bce4586971ad1abc33aac81\scratch\myPDFFILE.pdf')

Is it possible to explicitly call the function that convert the physical windows path to an url ?
If this is not possible, is there a better way to achieve what I'm trying to do ?

Outcomes