public static void main(String[] args) { // File file = new File("c:/Experiment/h2-2_MS_1_004.img.bz2"); File file = new File("c:/Experiment/baa5d5/high.mtz"); String serverLocation = "http://localhost:8161/fileserver/"; String filename = ""; String entryType = "ENTRY_CREATE"; String ID = "c:/Experiment/5d5.mtz"; URL url = null; // Generate checksum for the file here byte[] fileContents; try { fileContents = FileUtil.getBytesFromFile(file); filename = "5d5.mtz"; // FileUtil.getFileName("c:/Experiment/h2-2_MS_1_002.bz2"); url = new URL(serverLocation + filename); MD5ChecksumProcessor c = new MD5ChecksumProcessor(); String checksum = c.generateChecksum(file); String domain = "crystallography"; ADQueueWriterImpl qu = new ADQueueWriterImpl(); // upload a file to a webserver FileServerClient client = new FileServerClient(url); // boolean uploaded = client.upload(fileContents); // If upload is true send a blob message with this file url // if (uploaded=true){ // qu.sendBlobMessage(url,ID,domain,checksum,entryType,"12/10/2010 12:22:22"); try { qu.sendByteArrayMessage( fileContents, ID, checksum, domain, "baa5d5", entryType, "12/10/2010 12:22:22"); } catch (XMLStreamException e) { // TODO Auto-generated catch block e.printStackTrace(); } // } // qu.sendMessage(fileContents, ID, entryType, ""); // qu.sendBlobMessage("c:/Experiment/hello123.xml", "123.xml"); qu.disconnect(); } catch (JMSException e) { // TODO Auto-generated catch block e.printStackTrace(); // } catch (XMLStreamException e) { // TODO Auto-generated catch block // e.printStackTrace(); } catch (FactoryConfigurationError e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ChecksumProcessorException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public boolean uploadFileToServer(String ID, URL fileURL) { File file = new File(ID); byte[] fileContents; boolean uploaded = false; FileServerClient client = new FileServerClient(fileURL); try { fileContents = FileUtil.getBytesFromFile(file); uploaded = client.upload(fileContents); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } return uploaded; }