Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Can't download bitstream from API #262

Open
nholthaus opened this issue Oct 21, 2016 · 2 comments
Open

Can't download bitstream from API #262

nholthaus opened this issue Oct 21, 2016 · 2 comments

Comments

@nholthaus
Copy link

nholthaus commented Oct 21, 2016

version: 3.4.2

host: Ubuntu 14.04 (VM)

I have what I believe to be a working instance of Midas running. I'm able to upload/download files successfully when using the web interface.

However, I can't seem to download files via the API, which is what I really care about since I want to use Midas as a CMake external data store.

I have a bitstream, "10", which exists and returns the following from GET /rest/bitstream/10:

{
    "data":
    {
        "id":"10",
        "item_id":"10",
        "itemrevision_id":"9",
        "name":"singleFileTestPDWData_20160601.tar.gz",
        "mimetype":"application\/x-gzip",
        "size":"8395640",
        "md5":"74b552573f3ac17f4a270f5f38c6c442",
        "date_created":"2016-10-20 17:44:07",
        "date_updated":"2016-10-20 17:44:07"
    }
}

But when I try to access the file via the download URLs, either:

"http://midas.mit.edu/rest/bitstream/download/10"

or

"http://midas.mit.edu/rest/bitstream/download?checksum=74b552573f3ac17f4a270f5f38c6c442"

I get the following error:

The system has encountered the following error:

Call to undefined method Zend_Controller_Request_Http::dispatchError()
In /var/www/midas.mit.edu/html/library/REST/Controller/Plugin/RestHandler.php, line: 176
At 12:28:03 2016-10-21

Please notify your administrator with this information. 

And if I try to curl it, nothing is downloaded, and I get the following:

$ curl -vvv -o file.tar.gz "http://midas.mit.edu/rest/bitstream/download/10"`

> GET /rest/bitstream/download/10 HTTP/1.1
> User-Agent: curl/7.35.0
> Host: midas.mit.edu
> Accept: */*
> 
< HTTP/1.1 302 Found
< Date: Fri, 21 Oct 2016 12:44:23 GMT
* Server Apache/2.4.7 (Ubuntu) is not blacklisted
< Server: Apache/2.4.7 (Ubuntu)
< X-Powered-By: PHP/5.5.9-1ubuntu4.20
< Set-Cookie: PHPSESSID=3thup2nfv4arsbc9jq0djf1e75; path=/; HttpOnly
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
< Pragma: no-cache
< Vary: Accept
< Access-Control-Max-Age: 86400
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Headers: Authorization, X-Authorization, Origin, Accept, Content-Type, X-Requested-With, X-HTTP-Method-Override
< Access-Control-Allow-Methods: OPTIONS, HEAD, GET, PUT, DELETE, POST
< Location: /download/?bitstream=10&offset=0&name=singleFileTestPDWData_20160601.tar.gz
< Content-Length: 0
< Content-Type: application/json
< 
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
* Connection #0 to host midas.mit.edu left intact

and the production.log file shows:

2016-10-21T12:09:07+00:00 CRIT (2): Fatal Error: Array
(
    [type] =&gt; 1
    [message] =&gt; Call to undefined method Zend_Controller_Request_Http::dispatchError()
    [file] =&gt; /var/www/midas.mit.edu/html/library/REST/Controller/Plugin/RestHandler.php
    [line] =&gt; 176
    [typeText] =&gt; E_ERROR
)


URL: http://midas.mit.edu/rest/bitstream/download?checksum=74b552573f3ac17f4a270f5f38c6c442

Server time: 2016-10-21 12:09:07
Parameters (post): Array
(
)
Parameters (get): Array
(
    [checksum] =&gt; 74b552573f3ac17f4a270f5f38c6c442
)

The permissions on the file are set to public, and I've tried the download with an authorization token as well, with the same results.

@mgrauer
Copy link
Contributor

mgrauer commented Oct 21, 2016

@nholthaus

Try changing your URL to be like

http://midas.mit.edu/api/rest?method=midas.bitstream.download&checksum=%(hash)

and it is possible you may need to add &algorithm=%(algo)

Do you have the option to move away from Midas and to Girder? Girder is so much better, and much better supported.

There is support for External Data in Girder through a core plugin hashsum_download that you'll need to enable. This currently only supports sha512 hash through the filesystem assetstore. The docs could definitely be better (err, exist) for this plugin. I realize I'm not making the strongest case for the move in this particular case, but the platform really is much better.

If you run into trouble, you can post an Issue in Girder's Github, and you will get help.

@nholthaus
Copy link
Author

@mgrauer Thanks for the help, I'll try out the method call tomorrow. It seems like it actually does work with wget and cmake, just not curl or the web browser. In any case, I'd prefer to stay with a well-supported platform so I plan to set up a girder instance. Just wish that I had heard about it before we decided on Midas! The CMake ExternalData documentation really needs an update.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants