Skip to content

UploadShapeFile #1

Description

@GoogleCodeExporter
What steps will reproduce the problem?
1. When method upload shp is used final file has wrong data

Following change is made to correct output corrected ....
// this defenition is added
private URL zip;

public String uploadShape(String workspace, String dsName, URL zip)
            throws IOException {

        InputStream os = zip.openStream();
        this.zip = zip; // this value is added 
        try {
            InputStreamReader postDataReader = new InputStreamReader(os);

            String returnString = sendRESTstring(METHOD_PUT, "/workspaces/"
                    + workspace + "/datastores/" + dsName + "/file.shp",
                    postDataReader, "application/zip", null);

            // "?configure=all"
            return returnString;
        } finally {
            os.close();
        }
    }

method sendRest is corrected to send correct binary data 
        connection.connect();
        if (connection.getDoOutput()) {
    OutputStream out = connection.getOutputStream();
            InputStream in = zip.openStream();

            char[] buffer = new char[1024];
            byte[] ioBuf = new byte[4096];
            int bytesRead;

            int n;
            while ((bytesRead = in.read(ioBuf)) != -1)
                out.write(ioBuf, 0, bytesRead);
            out.close();
            in.close();

        }
        return connection;
    }

Original issue reported on code.google.com by vtavakk...@gmail.com on 26 Oct 2011 at 12:10

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions