Examples of StoredFile


Examples of com.cloudinary.StoredFile

    public void setCreatedAt(Date createdAt) {
        this.createdAt =  createdAt;
    }

    public StoredFile getUpload() {
        StoredFile file = new StoredFile();
        file.setPreloadedFile(image);
        return file;
    }
View Full Code Here

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

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


    @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

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

        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

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

            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

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

            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

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

            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

Examples of net.sf.archimede.model.storedFile.StoredFile

        List files = this.oldFolder.getFiles();
        for (Iterator it = files.iterator(); it.hasNext(); ) {
            String filePath = (String) it.next();
            File file = new File(filePath);
           
            StoredFile storedFile = new StoredFileImpl();
            InputStream is = new FileInputStream(filePath);
            storedFile.setData(is);
            GregorianCalendar cal = new GregorianCalendar();
            cal.setTimeInMillis(file.lastModified());
            storedFile.setLastModified(cal);
            storedFile.setMimeType( new MimetypesFileTypeMap().getContentType(file) );
            storedFile.setName(file.getName());
            storedFile.setParent(folder);
           
            if (storedFile.getReadUsers() == null) {
              storedFile.setReadUsers(new ArrayList());
            }
            storedFile.getReadUsers().add(new UserImpl("anonymous", ""));
           
            StoredFileDao.createInstance().save(storedFile);
            try {
        is.close();
      } catch (IOException e) {
View Full Code Here

Examples of net.sf.archimede.model.storedFile.StoredFile

            File currentFile = thesisFiles[i];
            System.out.println("Importing: " + currentFile.getPath());
            if (currentFile.isDirectory()) {
                continue;
            }
            StoredFile currentStoredFile = new StoredFileImpl();

            try {
               
                InputStream is = new FileInputStream(currentFile);
                try {
                    currentStoredFile.setData(is);
                    GregorianCalendar lastModified = new GregorianCalendar();
                    lastModified.setTimeInMillis(currentFile.lastModified());
                    currentStoredFile.setName(currentFile.getName());
                    currentStoredFile.setLastModified(lastModified);
                    currentStoredFile.setParent(thesisFolder);
                    currentStoredFile.setMimeType(new MimetypesFileTypeMap().getContentType(currentFile));
                    storedFiles.add(currentStoredFile);
                   
                    if (currentStoredFile.getReadUsers() == null) {
                        currentStoredFile.setReadUsers(new ArrayList());
                    }
                    currentStoredFile.getReadUsers().add(new UserImpl("anonymous", ""));
                   
                    StoredFileDao.createInstance().save(currentStoredFile);
                } finally {
                    is.close();
                }
View Full Code Here

Examples of net.sf.archimede.model.storedFile.StoredFile

            List storedFilesList = this.folder.getStoredFiles();
           
            //Look for "root" files names
            List rootFiles = new ArrayList();
            for (Iterator it = this.folder.getStoredFiles().iterator(); it.hasNext(); ) {
                StoredFile currentFile = (StoredFile) it.next();
                if (currentFile.getName().equals(this.folder.getName() + ".html") || currentFile.getName().equals(this.folder.getName() + ".pdf")) {
                    rootFiles.add(new ViewStoredFile(currentFile));
                }
            }
            if (rootFiles.size() > 0) {
                Collections.sort(rootFiles, new ContentSortComparator());
                this.storedFiles.setWrappedData(rootFiles);
                return this.storedFiles;
            }
           
            List viewStoredFilesList = new ArrayList(storedFilesList.size());
            for (Iterator it = storedFilesList.iterator(); it.hasNext(); ){
                StoredFile storedFile = (StoredFile) it.next();
                viewStoredFilesList.add(new ViewStoredFile(storedFile));
            }
            Collections.sort(viewStoredFilesList, new ContentSortComparator());
            this.storedFiles.setWrappedData(viewStoredFilesList);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.