Hi there,
I am trying to upload files using REST API but for some reason, when I 
download these files, I see
a content-disposition header along with a number that is on top and bottom. 
Here's an example:


--3920b9ce37f4e3292af6d8081aa02501                                              
                    

1 Content-Disposition: form-data; name="file"; filename="TODO"

...file content...

--3920b9ce37f4e3292af6d8081aa02501--

I tried to send this with and without header, but regardless the outcome is 
same. I suspect that upon saving
these files, DSpace mistakenly adds this header to file content. 

I tried to upload using python and bash, I'm adding the code snippets in 
case if they provide any useful information.

*Python:*
PARAMS = {'Accept': "application/json",
          'Content-Type': "application/json"}

def upload_file(file_path, item_uuid, cookie):
    """ Upload file to a DSpace item.

    Arguments:
    file      -- The path of file to upload.
    item_uuid -- The item UUID in the rest api.
    cookie    -- JSESSIONID for authentication.
    """

    # Add JSESSIONID to request header
    parameters = PARAMS
    parameters["Cookie"] = "JSESSIONID=" + cookie
    parameters["Content-Type"] = "multipart/form-data"

    # Prepare files dict for request
    file = open(file_path, 'rb')
    files = {'file': file}

    response = requests.post(url=URL + "/rest/items/" + item_uuid +
"/bitstreams?name=" + os.path.basename(file.name),
                             files=files, headers=parameters)
    pdb.set_trace()

    file.close()



*Bash:*
curl -k -v -4 --trace dspace.log --cookie 
"JSESSIONID=2C20ADE1EEC3EA7E225C32884A31EC59" -H "Accept: application/json" 
-X POST 
"http://localhost:8080/rest/items/46309f1d-c5fd-4142-80d7-3c850b5f955b/bitstreams?name=test.sh";
 
-T test.sh



Here's the information that you might need:

*OS*:
Manjaro Linux 19.0.2

*Tomcat:*
Server version: Apache Tomcat/8.5.51
Server built:   Feb 5 2020 22:26:25 UTC
Server number:  8.5.51.0
OS Name:        Linux
OS Version:     5.4.23-1-MANJARO
Architecture:   amd64
JVM Version:    1.8.0_242-b08
JVM Vendor:     Oracle Corporation

*Maven:*
Apache Maven 3.6.3 (NON-CANONICAL_2019-11-27T20:26:29Z_root)
Maven home: /opt/maven
Java version: 1.8.0_242, vendor: Oracle Corporation, runtime: 
/usr/lib/jvm/java-8-openjdk/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.4.23-1-manjaro", arch: "amd64", family: "unix"

*Ant:*
Apache Ant(TM) version 1.10.7 compiled on September 10 2019

*DSpace:*
DSpace version:  6.3
  SCM revision:  813800ce1736ec503fdcfbee4d86de836788f87c
    SCM branch:  UNKNOWN
            OS:  Linux(amd64) version 5.4.23-1-MANJARO
  Applications:
                REST at http://localhost:8080/xmlui
                XMLUI at http://localhost:8080/xmlui
                REST at http://localhost:8080/xmlui
                XMLUI at http://localhost:8080/xmlui
                REST at http://localhost:8080/xmlui
                XMLUI at http://localhost:8080/xmlui
     Discovery:  enabled.
           JRE:  Oracle Corporation version 1.8.0_242
   Ant version:  Apache Ant(TM) version 1.10.7 compiled on September 10 2019
 Maven version:  3.3.9
 DSpace home:  /dspace

Any help would be appreciated ^_^

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/dspace-tech/20fc0555-370d-4ab7-9957-f4575431f65c%40googlegroups.com.

Reply via email to