src/main/java/org/trellisldp/http/MultipartUploader.java
/**
     * Create a binary from a collection of uploaded parts
     * @param partition the partition
     * @param id the identifier
     * @param input the input value
     * @return a response
     *
     * <p>Note: The structure should be like this:</p>
     * <pre>{
     *   "1": "somehash",
     *   "2": "otherhash",
     *   "3": "anotherhash"
     * }</pre>
     */
Create a binary from a collection of uploaded parts
@param partition the partition
@param id the identifier
@param input the input value
@return a response


Create a binary from a collection of uploaded parts @param partition the partition @param id the identifier @param input the input value @return a response
@POST
    @Timed
    @Consumes("application/json")
    public Response createBinary(@PathParam("partition") final String partition,
            @PathParam("id") final String id, final InputStream input) {
        final JsonReader reader = Json.createReader(input);
        final JsonObject obj = reader.readObject();
        reader.close();
        final Map<Integer, String> partDigests = obj.keySet().stream()
            .collect(toMap(Integer::parseInt, obj::getString));
        return binaryService.getResolverForPartition(partition)
            .filter(BinaryService.Resolver::supportsMultipartUpload)
            .filter(svc -> svc.uploadSessionExists(id))
            .map(svc -> svc.completeUpload(id, partDigests))
            .map(upload -> {
                try (final TrellisDataset dataset = TrellisDataset.createDataset()) {
                    final IRI identifier = rdf.createIRI(TRELLIS_PREFIX + upload.getPath());
                    audit.creation(identifier, upload.getSession()).stream()
                        .map(skolemizeQuads(resourceService, upload.getBaseUrl())).forEachOrdered(dataset::add);
                    dataset.add(rdf.createQuad(PreferServerManaged, identifier, type, NonRDFSource));
                    dataset.add(rdf.createQuad(PreferServerManaged, identifier, DC.hasPart,
                                upload.getBinary().getIdentifier()));
                    dataset.add(rdf.createQuad(PreferServerManaged, upload.getBinary().getIdentifier(), DC.format,
                                rdf.createLiteral(upload.getBinary().getMimeType().orElse(APPLICATION_OCTET_STREAM))));
                    upload.getBinary().getSize().ifPresent(size -> dataset.add(rdf.createQuad(PreferServerManaged,
                                    upload.getBinary().getIdentifier(), DC.extent,
                                    rdf.createLiteral(size.toString(), XSD.long_))));
                    if (resourceService.put(identifier, dataset.asDataset())) {
                        return created(create(upload.getBaseUrl() + upload.getPath())).build();
                    }
                }
                LOGGER.error("Could not persist data");
                return serverError().entity("Could not persist data internally").build();
            })
            .orElseThrow(NotFoundException::new);
    }
@ POST @ Timed @ Consumes ( "application/json" ) public Response createBinary ( @ PathParam ( "partition" ) final String partition , @ PathParam ( "id" ) final String id , final InputStream input ) { final JsonReader reader = Json . createReader ( input ) ; final JsonObject obj = reader . readObject ( ) ; reader . close ( ) ; final Map < Integer , String > partDigests = obj . keySet ( ) . stream ( ) . collect ( toMap ( Integer :: parseInt , obj :: getString ) ) ; return binaryService . getResolverForPartition ( partition ) . filter ( BinaryService . Resolver :: supportsMultipartUpload ) . filter ( svc -> svc . uploadSessionExists ( id ) ) . map ( svc -> svc . completeUpload ( id , partDigests ) ) . map ( upload -> { try ( final TrellisDataset dataset = TrellisDataset . createDataset ( ) ) { final IRI identifier = rdf . createIRI ( TRELLIS_PREFIX + upload . getPath ( ) ) ; audit . creation ( identifier , upload . getSession ( ) ) . stream ( ) . map ( skolemizeQuads ( resourceService , upload . getBaseUrl ( ) ) ) . forEachOrdered ( dataset :: add ) ; dataset . add ( rdf . createQuad ( PreferServerManaged , identifier , type , NonRDFSource ) ) ; dataset . add ( rdf . createQuad ( PreferServerManaged , identifier , DC . hasPart , upload . getBinary ( ) . getIdentifier ( ) ) ) ; dataset . add ( rdf . createQuad ( PreferServerManaged , upload . getBinary ( ) . getIdentifier ( ) , DC . format , rdf . createLiteral ( upload . getBinary ( ) . getMimeType ( ) . orElse ( APPLICATION_OCTET_STREAM ) ) ) ) ; upload . getBinary ( ) . getSize ( ) . ifPresent ( size -> dataset . add ( rdf . createQuad ( PreferServerManaged , upload . getBinary ( ) . getIdentifier ( ) , DC . extent , rdf . createLiteral ( size . toString ( ) , XSD . long_ ) ) ) ) ; if ( resourceService . put ( identifier , dataset . asDataset ( ) ) ) { return created ( create ( upload . getBaseUrl ( ) + upload . getPath ( ) ) ) . build ( ) ; } } LOGGER . error ( "Could not persist data" ) ; return serverError ( ) . entity ( "Could not persist data internally" ) . build ( ) ; } ) . orElseThrow ( NotFoundException :: new ) ; }
Create a binary from a collection of uploaded parts
 @param partition the partition
 @param id the identifier
 @param input the input value
 @return a response
Create a binary from a collection of uploaded parts @param partition the partition @param id the identifier @param input the input value @return a response
// Add Audit quads