1

I would like to create a file with an ArcGIS Server Object Extension and return the url. Is this possible? Where would I write the file?

I'm working with .Net, IIS, and AGS 10.1.

2

It is possible. First, you need to register output directory or parent directory as "Data store". Because, ArcGIS Server 10.1 can only access to "Data store" directory. Next, add the output directory as IIS Virtual directory. Then, you can create file to output directory and access it from IIS.

To get more information about Data store, please follow,
Registering your data with ArcGIS Server using Manager

Here is the sample code. This code is from REST template.

private byte[] RootResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties) {
    responseProperties = null;

    //c:\data is "Data store" directory
    //c:\data\test is "output diretory" and register as IIS virtual directory named "test"
    System.IO.FileStream fs = new System.IO.FileStream(@"c:\data\test\sample.txt", System.IO.FileMode.CreateNew, System.IO.FileAccess.Write);
    System.IO.StreamWriter sw = new System.IO.StreamWriter(fs);

    using(fs)
    using (sw) {

        sw.WriteLine("hello");
        sw.Flush();
    }

    //return url as string value
    JsonObject result = new JsonObject();
    result.AddString("url", "http://<host>/test/sample.txt");

    return Encoding.UTF8.GetBytes(result.ToJson());
}

Hope this help you.

0

in ags server 10.1, the server directory arcgisserver can be access with the url, you do not need to register it, so i always export a file,special an image file in the arcgisserver directory and then given the url to the client.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.