Package org.ektorp

Examples of org.ektorp.AttachmentInputStream





    protected File downloadLocalZip(File storeDir, CouchDbConnector connector, String designDoc, String attachmentName) throws IOException {
        AttachmentInputStream is = connector.getAttachment(designDoc, attachmentName);
        File zipFile = new File(storeDir,"ffmpeg.zip");
        FileUtils.copyInputStreamToFile(is, zipFile);
        return zipFile;
    }
View Full Code Here


                for (Iterator<String> i = attachments.getFieldNames(); i.hasNext(); ) {
                    String attachmentName = i.next();
                   
                    EventBus.publish(new LoadingMessage(0, 0, "Downloading Data", currentAttachment++, totalAttachments, "Copy data from " + cachedUrl ));
                    System.out.println("Copy attachment  " + currentAttachment  +   " : " + attachmentName);
                    AttachmentInputStream in = src.getAttachment(row.getId(), attachmentName);

                    String rev = dest.createAttachment(row.getId(), design.get("_rev").getTextValue() , in);
                    try {
                        in.close();
                    } catch (IOException ex) {
                        Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    design.put("_rev", rev);
                }
View Full Code Here

               
                String revision = currentRecordingDoc.get("_rev").getTextValue();
                try {
                    // mp3
                    FileInputStream fis = new FileInputStream(t.getRecordings()[0]);
                    AttachmentInputStream ais = new AttachmentInputStream("complete.mp3",fis, "audio/mp3");
                    revision = connector.createAttachment(id, revision, ais);
                    ais.close();
                    fis.close();
                } catch(Exception e) {

                }
                try {
                    if (t.getRecordings().length == 2){
                        // ogg
                        FileInputStream fis = new FileInputStream(t.getRecordings()[1]);
                        AttachmentInputStream ais = new AttachmentInputStream("complete.ogg",fis, "audio/ogg");
                        revision = connector.createAttachment(id, revision, ais);
                        ais.close();
                        fis.close();
                    }
                } catch (Exception e) {

                }
                EventBus.publish(new UploadingFinishedEvent());


                // lame extra get
                currentRecordingDoc = loadRecordingDoc(id);
                ObjectNode recordingState = getRecordingState(currentRecordingDoc);
                recordingState.put("recordingComplete", new Date().getTime());
                connector.update(currentRecordingDoc);
                currentRecordingDoc = null;
            }
        });

        EventBus.subscribeStrongly(StreamReadyEvent.class, new EventSubscriber<StreamReadyEvent>() {
            @Override
            public void onEvent(StreamReadyEvent t) {
                System.out.println("Streaming");
                if (streamAudio) {
                    try {


                        System.out.println("out");
                        // create a doc
                        ObjectMapper map = new ObjectMapper();
                        ObjectNode node = map.createObjectNode();
                        node.put("type", "com.eckoit.recordingSegment");
                        node.put("recording", currentRecordingDoc.get("_id").getTextValue());
                        node.put("startTime", t.getStartTime());
                        connector.create(node);

                        String id = node.get("_id").getTextValue();
                        String rev = node.get("_rev").getTextValue();
                        {
                            // attach stream
                            FileInputStream fis = new FileInputStream(t.getAvailableToStream());
                            String name = "fileSequence" + t.getSegmentCount() + ".ts";
                            AttachmentInputStream ais = new AttachmentInputStream(name,fis, t.getContentType());

                           
                            rev =  connector.createAttachment(id, rev, ais);
                            ais.close();
                            fis.close();
                        }
                        {
                            // attach mp3
                            FileInputStream fis = new FileInputStream(t.getFinishedFile());
                            String name = "fileSequence" + t.getSegmentCount() + ".mp3";
                            AttachmentInputStream ais = new AttachmentInputStream(name,fis, "audio/mp3");

                            rev =  connector.createAttachment(id, rev, ais);
                            ais.close();
                            fis.close();
                        }
                       
                   
                    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.ektorp.AttachmentInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.