Hello,
I have no problem with header with this code to upload a bistream file with
Rest :
File file = new File(cheminFic);
FileEntity entityFic = new FileEntity(file,
ContentType.create("application/octet-stream", "UTF-8"));
requetePost.setEntity(entityFic);
Best regards,
Cedric
________________________________
De : [email protected] [mailto:[email protected]] De la
part de Mehrdad Pedram
Envoyé : samedi 8 avril 2017 07:14
À : DSpace Technical Support
Objet : [dspace-tech] Re: Bitstream header problem using REST API
Any update on this? I'm having the same issue.
On Wednesday, February 10, 2016 at 2:53:20 PM UTC+3:30, Elektronac wrote:
Hi,
I have a problem with DSpace REST service when i upload bitstream file.
When I upload file, additional header is embedded inside of that bitstream file.
Because of that embedded header I am not able to view file from DSpace.
When I download bitstream file from DSpace, open it and erase header (from
notepad) i can view content of this file.
Do you have any sugestion how can I solve this problem?
Code for calling the DSpace REST service:
HttpPost post = new HttpPost(base_url +
"items/1/bitstreams?name=image.png&description=myTestiImage");
post.setHeader("rest-dspace-token",token);
post.addHeader("Content-Type", "multipart/form-data");
post.addHeader("Accept", "image/png");
MultipartEntity builder = new
MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
String path = "D:/image.png";
File postFile = new File(path);
FileBody cbFile = new FileBody(postFile);
builder.addPart("data", cbFile);
post.setEntity(builder);
System.out.println("executing request " + post.getRequestLine());
HttpResponse response = client.execute(post);
...
File header before upload:
‰PNG
...
Bitstream file header after uopload:
--AueSc1EQFoTUiaqVs7YQOgeVdx3wqdf2E0
Content-Disposition: form-data; name="someName"; filename="image.png"
Content-Type: image/png
Content-Transfer-Encoding: binary
‰PNG
...
--
You received this message because you are subscribed to the Google Groups
"DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
[email protected]<mailto:[email protected]>.
To post to this group, send email to
[email protected]<mailto:[email protected]>.
Visit this group at https://groups.google.com/group/dspace-tech.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/dspace-tech.
For more options, visit https://groups.google.com/d/optout.