Commit c13abebe authored by Chris Morris's avatar Chris Morris
Browse files

Suicide

parent bfae0667
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="VcsDirectoryMappings">
    <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
  </component>
</project>
 No newline at end of file
+17 −8
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ import edu.psu.MarkLogic.demo.model.ConfidenceFitness;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -95,14 +96,22 @@ public class MLRestController {
            provider.setCredentials(AuthScope.ANY, credentials);
            HttpClient httpClient = HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build();

            String uri = "http://192.168.56.200:8000/LATEST/documents?uri=/final-project/" /* + the name of the file we're trying to upload goes here */;           // provide the REST API URI
            String uri = "";

            HttpPut put = new HttpPut(uri);

            File file = null;          // provide the file object
            for (MultipartFile uploadfile : uploadfiles) {
                uri = "http://192.168.56.200:8000/LATEST/documents?uri=/final-project/" + uploadfile.getOriginalFilename();           // provide the REST API URI
                // convert the MultipartFile into a file
                File file = new File(uploadfile.getOriginalFilename());          // provide the file object
               file.createNewFile();
                FileOutputStream fout = new FileOutputStream(file);
                fout.write(uploadfile.getBytes());
                fout.close();
                FileEntity fe = new FileEntity(file, ContentType.create(uploadfiles[0].getContentType(), "UTF-8"));
                HttpPut put = new HttpPut(uri);
                // provide code that uses httpClient and fe to perform file creation
            
                httpClient.execute(put);
            }
        } catch (Exception e) {
            //-f, fail silently
            System.out.println(e);