Package com.infoclinika.mssharing.fileserver.model

Examples of com.infoclinika.mssharing.fileserver.model.StoredFile


    public StoredFile get(NodePath path) {
        LOGGER.debug("Obtaining the object from bucket = " + rawFilesBucket + " at node path = " + path);

        try {
            final S3ObjectInputStream objectContent = getAsStream(path);
            return new StoredFile(objectContent);
        } catch (AmazonClientException e) {
            final String message = "Cannot obtain the object from path " + path + ". Bucket name = " + rawFilesBucket;
            LOGGER.warn(message, e);
        }
        return null;
View Full Code Here



    @Test(enabled = false)
    public void testGetNonExistingFile() {
        final NodePath randomPath = new NodePath("non-existing-node-path" + System.currentTimeMillis());
        final StoredFile file = storageService.get(randomPath);
        assertNull(file, "File obtained at random path expected to be NULL, but it is not.");
    }
View Full Code Here

        try {
            Files.touch(file);
            Files.write("My test file contents".getBytes(), file);

            final NodePath nodePath = new NodePath("myuser/" + filename);
            final StoredFile storedFile = new StoredFile(new BufferedInputStream(new FileInputStream(file)));
            storageService.put(nodePath, storedFile);

            final StoredFile obtainedFile = storageService.get(nodePath);
            assertNotNull(obtainedFile, "Obtained file must not be NULL at path " + nodePath);

            final File tempDestFile = File.createTempFile("unit-test", null);
            final FileOutputStream fos = new FileOutputStream(tempDestFile);

            InputStream inputStream = obtainedFile.getInputStream();
            ByteStreams.copy(inputStream, fos);
            fos.flush();

            final boolean filesAreTheSame = Files.equal(file, tempDestFile);
            assertTrue(filesAreTheSame, "Source file and obtained file must have the same contents");
View Full Code Here

            response.sendError(404);
            return;
        }

        //todo[tymchenko]: code smell; Refactor File storage API to avoid this
        final StoredFile file = attachmentsUploadHelper.getContent(attachmentId, attachmentItem.ownerId);
        final InputStream is = file.getInputStream();

        response.setContentType("application/octet-stream");
        response.setHeader("Content-Disposition", "attachment; filename=" + attachmentItem.name);
        IOUtils.copy(is, response.getOutputStream());
View Full Code Here

            pushFileToZip(zos, item.name, new InputStreamProvider() {
                @Override
                public FilterInputStream get() {
                    //todo[tymchenko]: code smell; Refactor File storage API to avoid this
                    final StoredFile file = attachmentsUploadHelper.getContent(item.id, request.actor);
                    return file.getInputStream();
                }
            });
        }
    }
View Full Code Here

            response.sendError(404);
            return;
        }

        //todo[tymchenko]: code smell; Refactor File storage API to avoid this
        final StoredFile file = experimentSearchExportUploadHelper.getContent(experimentSearchId, rawFileId, userId, exportType);
        final InputStream is = file.getInputStream();

        response.setContentType("application/octet-stream");
        response.setHeader("Content-Disposition", "attachment; filename=" + experimentSearchItem.name + "_" + fileItem.name  + exportType.getFormat());
        IOUtils.copy(is, response.getOutputStream());
View Full Code Here

TOP

Related Classes of com.infoclinika.mssharing.fileserver.model.StoredFile

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.