Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3009 from atmire/w2p-72494_export-script-output-t…
…ravis-test Refactor/remove custom MultipartFileSender to use Spring Boot Range requests
- Loading branch information
Showing
7 changed files
with
381 additions
and
1,056 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
dspace-server-webapp/src/main/java/org/dspace/app/rest/utils/BitstreamResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* The contents of this file are subject to the license and copyright | ||
* detailed in the LICENSE and NOTICE files at the root of the source | ||
* tree and available online at | ||
* | ||
* http://www.dspace.org/license/ | ||
*/ | ||
package org.dspace.app.rest.utils; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.UUID; | ||
|
||
import org.springframework.core.io.AbstractResource; | ||
|
||
/** | ||
* This class acts as a {@link AbstractResource} used by Spring's framework to send the data in a proper and | ||
* streamlined way inside the {@link org.springframework.http.ResponseEntity} body. | ||
* This class' attributes are being used by Spring's framework in the overridden methods so that the proper | ||
* attributes are given and used in the response. | ||
*/ | ||
public class BitstreamResource extends AbstractResource { | ||
|
||
private InputStream inputStream; | ||
private String name; | ||
private UUID uuid; | ||
private long sizeBytes; | ||
|
||
public BitstreamResource(InputStream inputStream, String name, UUID uuid, long sizeBytes) { | ||
this.inputStream = inputStream; | ||
this.name = name; | ||
this.uuid = uuid; | ||
this.sizeBytes = sizeBytes; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "bitstream [" + uuid + "]"; | ||
} | ||
|
||
@Override | ||
public InputStream getInputStream() throws IOException { | ||
return inputStream; | ||
} | ||
|
||
@Override | ||
public String getFilename() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public long contentLength() throws IOException { | ||
return sizeBytes; | ||
} | ||
} |
Oops, something went wrong.