Skip to content
Snippets Groups Projects
Commit c13abebe authored by Chris Morris's avatar Chris Morris
Browse files

Suicide

parent bfae0667
No related branches found
No related tags found
No related merge requests found
<?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
...@@ -6,6 +6,7 @@ import edu.psu.MarkLogic.demo.model.ConfidenceFitness; ...@@ -6,6 +6,7 @@ import edu.psu.MarkLogic.demo.model.ConfidenceFitness;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
...@@ -95,14 +96,22 @@ public class MLRestController { ...@@ -95,14 +96,22 @@ public class MLRestController {
provider.setCredentials(AuthScope.ANY, credentials); provider.setCredentials(AuthScope.ANY, credentials);
HttpClient httpClient = HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build(); 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);
for (MultipartFile uploadfile : uploadfiles) {
File file = null; // provide the file object uri = "http://192.168.56.200:8000/LATEST/documents?uri=/final-project/" + uploadfile.getOriginalFilename(); // provide the REST API URI
FileEntity fe = new FileEntity(file, ContentType.create(uploadfiles[0].getContentType(), "UTF-8")); // convert the MultipartFile into a file
// provide code that uses httpClient and fe to perform file creation 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) { } catch (Exception e) {
//-f, fail silently //-f, fail silently
System.out.println(e); System.out.println(e);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment