Hi Phanuel

I use post's data parameter, not files.


See:

https://github.com/artefactual/archivematica-storage-service/blob/946a513da208f96c87b00f0ae86ad011d7e9baac/storage_service/locations/models/dspace_rest.py#L345-L359


Hope that helps

________________________________
From: [email protected] <[email protected]> on behalf of 
[email protected] <[email protected]>
Sent: 25 April 2019 07:33:07
To: DSpace Technical Support
Subject: [dspace-tech] REST Bitsream upload

I am able to upload bitstream files using REST API but the files cannot be 
opened and shows the "Error Failed to load PDF document."
What is it that I might be doing wrong.
Below is a code I use to upload bitsream to my server using python request.

items_link = "http://127.0.0.1:8080/rest/items/";

 with open(files_directory, 'rb') as f:
  file_response = requests.post(items_link+item["uuid"]+"/bitstreams",
                                files={file: f},
                                params={'name': file_name},
                                cookies={"JSESSIONID": 
"349896766C1Dxxxxxxxxxxxxxxxxx"})
  print(file_response.status_code)
  print(file_response.text)


The kind of response i get is as shown below.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<bitstream>
   <link>/rest/bitstreams/3bea2204-634e-45fd-8941-915e3a586650</link>
   <expand>parent</expand>
   <expand>policies</expand>
   <expand>all</expand>
   
<name>U14ProcKidaneCharacterizationNothomNodev.pdf-ca379004ec12bd1951751b1603d703a5.pdf</name>
   <type>bitstream</type>
   <UUID>3bea2204-634e-45fd-8941-915e3a586650</UUID>
   <bundleName>ORIGINAL</bundleName>
   <checkSum checkSumAlgorithm="MD5">65916a770d9c0b481076d22e1bad02a2</checkSum>
   <format>Adobe PDF</format>
   <mimeType>application/pdf</mimeType>
   
<retrieveLink>/rest/bitstreams/3bea2204-634e-45fd-8941-915e3a586650/retrieve</retrieveLink>
   <sequenceId>-1</sequenceId>
   <sizeBytes>3962951</sizeBytes>
</bitstream>



--
All messages to this mailing list should adhere to the DuraSpace Code of 
Conduct: https://duraspace.org/about/policies/code-of-conduct/
---
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.
The University of Edinburgh is a charitable body, registered in Scotland, with 
registration number SC005336.

-- 
All messages to this mailing list should adhere to the DuraSpace Code of 
Conduct: https://duraspace.org/about/policies/code-of-conduct/
--- 
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.

Reply via email to