Package org.restlet.representation

Examples of org.restlet.representation.FileRepresentation


    public static void main(String[] args) throws IOException {
        long startTime = System.currentTimeMillis();

        ClientResource resource = new ClientResource("http://localhost:8554/");
        FileRepresentation fr = new FileRepresentation("file:///c:/test.mpg",
                MediaType.VIDEO_MPEG);
        System.out.println("Size sent: " + fr.getSize());
        InputRepresentation ir = new InputRepresentation(fr.getStream(), fr
                .getMediaType());

        try {
            resource.post(ir);
        } catch (ResourceException e) {
View Full Code Here


    }

    public void testConstructors() {
        final File file = new File("test.txt");

        final FileRepresentation r = new FileRepresentation(file,
                MediaType.TEXT_PLAIN);

        assertEquals("test.txt", r.getDisposition().getFilename());
        assertEquals(MediaType.TEXT_PLAIN, r.getMediaType());
        assertNull(r.getExpirationDate());
    }
View Full Code Here

            @Override
            public Restlet createInboundRoot() {
                return new Restlet() {
                    @Override
                    public void handle(Request request, Response response) {
                        response.setEntity(new FileRepresentation(file,
                                MediaType.TEXT_PLAIN));
                        response.getEntity().getDisposition().setType(
                                Disposition.TYPE_ATTACHMENT);
                    }
                };
View Full Code Here

        Server server = new Server(new Context(), Protocol.HTTP, 8554,
                new Restlet() {
                    @Override
                    public void handle(Request request, Response response) {
                        FileRepresentation fr = new FileRepresentation(
                                "file:///c:/TEST/restlet-jse-2.0.5-ff.zip",
                                MediaType.APPLICATION_ZIP);
                        System.out.println("Size sent: " + fr.getSize());
                        response.setEntity(fr);
                    }
                });

        server.start();
View Full Code Here

  
   public Restlet createRoot() {
      return new Restlet(getContext()) {
         public void handle(Request request,Response response) {
            File f = new File("/tmp/"+request.getResourceRef().getRemainingPart());
            response.setEntity(new FileRepresentation(f,MediaType.TEXT_PLAIN));
            response.setStatus(Status.SUCCESS_OK);
         }
      };
   }
View Full Code Here

         backup.toDirectory(dir);
         zipDir(dir,zipFile);
         deleteDir(dir);
          */
         getResponse().setStatus(Status.SUCCESS_OK);
         Representation rep = new FileRepresentation(zipFile,MediaType.APPLICATION_ZIP) {
            public void release() {
               zipFile.delete();
            }
         };
         Disposition disposition = new Disposition();
         disposition.setFilename("backup.zip");
         rep.setDisposition(disposition);
         return rep;
      } catch (Exception ex) {
         getContext().getLogger().log(Level.SEVERE,"Cannot perform backup to due to exception: "+ex.getMessage(),ex);
         getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
         return new StringRepresentation("Cannot perform backup to due to exception.");
View Full Code Here

   }
  
   public Representation getFeedHead(String path,UUID id)
      throws IOException
   {
      return new FileRepresentation(makeFeedReference(path),MediaType.APPLICATION_ATOM_XML);
   }
View Full Code Here

  
   public Representation getMedia(String path,UUID feedId,String name
      throws IOException
   {
      File mediaFile = makeMediaReference(path,name);
      return new FileRepresentation(mediaFile,MediaType.APPLICATION_OCTET_STREAM);
   }
View Full Code Here

      this.db = db;
   }
  
   public Representation getRepresentation() {
      if (rep==null && name!=null) {
         rep = new FileRepresentation(getFile(),MediaType.APPLICATION_XML);
      }
      return super.getRepresentation();
   }
View Full Code Here

      this.additive = flag;
   }
  
   public Representation getRepresentation() {
      if (rep==null && name!=null) {
         rep = new FileRepresentation(getFile(),MediaType.APPLICATION_XML);
      }
      return super.getRepresentation();
   }
View Full Code Here

TOP

Related Classes of org.restlet.representation.FileRepresentation

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.