vendredi 2 octobre 2015

I can't retrieve large files from AWS Bucket using java sdk

I have a Bucket in the Region: Oregon, I'm using the aws java sdk, with small files I don't have problems but when I try to download a file of 40 MB I get a Network error in the browser.

I'm using Java, Primefaces and role based authentication.

ClientConfiguration clientConfig = new ClientConfiguration();
        clientConfig.setProtocol(Protocol.HTTP);
AmazonS3 s3= new AmazonS3Client(clientConfig);
s3.setRegion(Region.getRegion(Regions.US_WEST_2));

Method to get the file :

public StreamedContent getFile() {
        S3Object obj = s3.getObject(new GetObjectRequest(ProjectConstants.BUCKET_NAME,
                ProjectConstants.OBJECT_NAME));
        return new DefaultStreamedContent(obj.getObjectContent(), "application/octet-stream", "file.exe");
    }

Facelet code:

<h:form>
    <p:commandButton value="#{viewDow.button_download}" ajax="false" onclick="PrimeFaces.monitorDownload(start, stop);">
<p:fileDownload value="#{downloadController.file}" />
</p:commandButton>
</h:form>

Note: I don't get exceptions.

I get the next error :

enter image description here




Aucun commentaire:

Enregistrer un commentaire