Package com.dropbox.client2.session.Session

Examples of com.dropbox.client2.session.Session.ProxyInfo


        was.setAccessTokenPair(accessToken);
        DropboxAPI<WebAuthSession> api = new DropboxAPI<WebAuthSession>(was);
       
        try {
            Entry meta = api.metadata(filePath, 1, null, false, null);
            DropboxInputStream streamData = api.getFileStream(filePath, null);
           
            try
            {
                int bufferSize = 1024;
                byte[] buffer = new byte[bufferSize];
                ByteArrayOutputStream baos = new ByteArrayOutputStream(bufferSize);           
                int bytesread = 0;
                while(true){
                    bytesread = streamData.read(buffer);
                    if (bytesread == -1) break;
                    baos.write(buffer,0,bytesread);
                }
               
                String name = "";
                int offset = filePath.lastIndexOf("/");
                if (offset!=-1) name = filePath.substring(offset+1);
               
                res.setContentType(meta.mimeType);    
                if (!"".equals((name)))
                    res.setHeader("Content-Disposition", "attachment; filename=" + name);
                res.setHeader("Cache-Control", "no-cache");   
                res.setContentLength(baos.size());
                ServletOutputStream sos = res.getOutputStream();
                baos.writeTo(sos);
                sos.flush();
                streamData.close();
                return null;
            }
            catch(Exception ex)
            {
                ex.printStackTrace();
View Full Code Here


        AccessTokenPair accessToken = new AccessTokenPair(tokenKey, tokenSecret);
        was.setAccessTokenPair(accessToken);
        DropboxAPI<WebAuthSession> api = new DropboxAPI<WebAuthSession>(was);
       
        try {
            Entry meta = api.metadata(filePath, 1, null, false, null);
            DropboxInputStream streamData = api.getFileStream(filePath, null);
           
            try
            {
                int bufferSize = 1024;
View Full Code Here

        }

        session.sign(req);
        HttpResponse resp = execute(session, req);

        return new RequestAndResponse(req, resp);
    }
View Full Code Here

        isEntity.setChunked(false);

        HttpEntity entity = isEntity;

        if (listener != null) {
            entity = new ProgressHttpEntity(entity, listener);
        }

        req.setEntity(entity);

        return new BasicUploadRequest(req, session);
View Full Code Here

                }

                try {
                    post.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
                } catch (UnsupportedEncodingException e) {
                    throw new DropboxException(e);
                }
            }

            req = post;
        }
View Full Code Here

            } else {
                // This is from Dropbox, and we shouldn't be getting it
                throw new DropboxParseException(bin);
            }
        } catch (OutOfMemoryError e) {
            throw new DropboxException(e);
        } finally {
            if (bin != null) {
                try {
                    bin.close();
                } catch (IOException e) {
View Full Code Here

        } catch (IOException e) {
            // Quite common for network going up & down or the request being
            // cancelled, so don't worry about logging this
            throw new DropboxIOException(e);
        } catch (OutOfMemoryError e) {
            throw new DropboxException(e);
        }
    }
View Full Code Here

            // handle errors better.
            super(null);

            HttpEntity entity = response.getEntity();
            if (entity == null) {
                throw new DropboxException("Didn't get entity from HttpResponse");
            }

            // Now set the input stream on FilterInputStream. This will throw
            // an IOException itself if something goes wrong.
            try {
View Full Code Here

                JSONParser parser = new JSONParser();
                result = parser.parse(bin);
            }
        } catch (IOException e) {
            throw new DropboxIOException(e);
        } catch (ParseException e) {
            if (DropboxServerException.isValidWithNullBody(response)) {
                // We have something from Dropbox, but it's an error with no reason
                throw new DropboxServerException(response);
            } else {
View Full Code Here

        Scanner scanner;
        try {
            scanner = new Scanner(entity.getContent()).useDelimiter("&");
        } catch (IOException e) {
            throw new DropboxIOException(e);
        }

        Map<String, String> result = new HashMap<String, String>();

        while (scanner.hasNext()) {
View Full Code Here

TOP

Related Classes of com.dropbox.client2.session.Session.ProxyInfo

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.