class FileUploader {

    public String upload() throws IOException, URISyntaxException
    {
        ResponseValues response = new ResponseValues();

        String thePermalink = null;

        Map<String, String> metaDataParts = getMetadataParts();
        InputStream returnStream;
        if (metaDataParts.isEmpty())
        {
            returnStream = myServer.postFile(new URL(myUrl), myFile, response);
        }
        else
        {
            returnStream = getServer().postFile(new URL(getUrl()), metaDataParts, getFile(), response);
        }
        try
        {
            if (response.getResponseCode() == HttpURLConnection.HTTP_OK)
            {
                ObjectMapper mapper = JsonUtils.createMapper();
                UploadResponse uploadResponse = mapper.readValue(returnStream, UploadResponse.class);
                if (uploadResponse.isSuccess())
                {
                    thePermalink = uploadResponse.getUrl();
                }
                else
                {
                    throw new IOException("File failed to upload.");
                }
            }
            else
            {
                throw new IOException(response.getResponseMessage());
            }
        }
        finally
        {
            returnStream.close();
        }

        return thePermalink;
    }

    public  FileUploader(File file, HttpServer server, String url);

}