No ha encontrado la respuesta aquí? Regístrate, preguntar y obtener una respuesta adecuada en cuestión de minutos!
  • Username:

Para poder verificar esta petición, por favor escribe en el campo de abajo lo siguiente: forodejava

Password:
Confirm Password:
Your Email:
Confirm Email:
Resultados 1 al 2 de 2
  1. #1
    Fecha de ingreso
    10 feb, 12
    Mensajes
    1
    Post Thanks / Like
    Poder de reputación
    0

    Predeterminado Subir Archivos Via Rest

    Buenas noches a todos, tengo el siguiente inconveniente. Tengo que subir un archivo por pedazos a través de un servicio expuesto en rest. He logrado subir el archivo completo mediante este codigo:

    ClientConfig cc = new DefaultClientConfig();
    cc.getClasses().add(MultiPartWriter.class);
    Client client = Client.create(cc);
    WebResource web = client.resource("https://storage.cloudlayer.com/v1/files/");

    File archivo = new File("ruta.txt")
    FormDataMultiPart part = new FormDataMultiPart();

    FileDataBodyPart file = new FileDataBodyPart();
    file.setName("filename");
    file.setFileEntity(archivo,MediaType.APPLICATION_O CTET_STREAM_TYPE);
    part.bodyPart(file);

    part.field("output","json");

    String response = web.type(MediaType.MULTIPART_FORM_DATA_TYPE).post( String.class, part);

    pero no logro enviar el mismo parte por parte. A continuación anexo lo que son las instrucciones de conexión con este api para ver si me pueden ayudar a interpretarlo y lograr el cometido.

    How to Upload a File One Part At a Time To transfer a file one piece at a time, a file create then a series of file updates are
    performed then the new file is unlocked. Each piece of the file can be of any size. The first piece is transferred as part of the create,
    which returns the file OID and the lock ID. All subsequent pieces are transferred as updates to the new file, with each subsequent
    piece modifying the file OID returned from the create and passing in the lock ID returned from the create. In each update, the
    offset of the new piece from the beginning of the file must be specified. Offsets are specified using the HTTP “Content-Range”
    header field. At the end, the lock ID returned by the create is unlocked using the lock command.
    An example might be helpful. To upload a file called “example” in 100 byte pieces, an HTTP post is made to “/v1/files/” with
    the body containing the first 100 bytes (offsets 0-99) of the file. It returns a file OID and a lock ID, in this case the file OID is
    “57CC826C-4B70-4A96-B665-08A953573C70” and the lock ID is “66DB917B-5C7F-5BA5-C756-17B862664B8F.” The bytes 100-199 of
    the file are transferred by doing a POST to “/v1/files/57CC826C-4B70-4A96-B665-08A953573C70” making sure that there is an HTTP
    header “Content-Range: 100-199” and another one with “X-Mezeo-Lock: 66DB917B-5C7F-5BA5-C756-17B862664B8F” and including
    the 100 bytes starting at offset 100 in the file. The third block, 200-299 is transferred by doing a post to “/v1/files/57CC826C-
    4B70-4A96-B665-08A953573C70” making sure that there is an HTTP header “Content-Range: 200-299” and another one with
    “X-Mezeo-Lock: 66DB917B-5C7F-5BA5-C756-17B862664B8F” and including the 100 bytes starting at offset 200 in the file. This
    continues until the last block has been transferred.

    La solución completa para el hilo: aquí.



    At the end, a POST to “/v1/files/57CC826C-4B70-4A96-B665-08A953573C70/lock” is performed, specifying an “action” parameter
    with the value “unlock” and a “lockid” parameter with the value “66DB917B-5C7F-5BA5-C756-17B862664B8F.” This unlocks the file.
    When uploading a file a piece at a time, performance can be improved by delaying finalization until the end of the transfer. This is
    done by including an “X-Mezeo-Suppress-Finalize” HTTP header field.Messages that do not contain an “X-Mezeo-Suppress-Finalize”
    will finalize the file after every transfer. Therefore, the last transfer would not include the “X-Mezeo-Suppress-Finalize” HTTP
    header so that the finalization steps can be completed.

    Agradeceria Enormemente su ayuda, de antemano muchas gracias

  2. #2
    Fecha de ingreso
    02 nov, 09
    Ubicación
    Sabadell
    Mensajes
    1,959
    Post Thanks / Like
    Poder de reputación
    1440

    Predeterminado

    No ha encontrado la
    respuesta aquí?
    Regístrate, preguntar y
    obtener una respuesta
    adecuada en cuestión de minutos!


    Un registro de minutos: clic

    Sin publicidad para los miembros!
    no se que es eso de subir ficheros via rest.

Temas similares

  1. Respuestas: 3
    Último mensaje: 30/01/2012, 08:44
  2. Subir applet a internet
    Por superdog13 en el foro Java Básico
    Respuestas: 1
    Último mensaje: 08/03/2011, 05:24
  3. subir archivo
    Por mike_veces en el foro JSP y Servlet
    Respuestas: 1
    Último mensaje: 30/09/2010, 08:31
  4. Subir aplicación Java a un servidor
    Por darupi en el foro Java avanzado
    Respuestas: 11
    Último mensaje: 16/07/2009, 23:53
  5. Cómo subir un archivo jsp?
    Por caro79 en el foro JSP y Servlet
    Respuestas: 3
    Último mensaje: 26/05/2008, 15:51

Permisos de publicación

  • No puedes crear nuevos temas
  • No puedes responder temas
  • No puedes subir archivos adjuntos
  • No puedes editar tus mensajes
  •