aldefouw / redcap-api-transfer

This project contains Ruby libraries that aim to make transferring a REDCap project from one server to another as simple as running a single script from command line.
6 stars 1 forks source link

Issue when trying to transfer uploaded files #1

Closed senorrojo closed 4 years ago

senorrojo commented 4 years ago

When trying to transfer records (single or all records) with an uploaded file attached, I get the below error:

$ ruby -v ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-linux]

$ ruby single_record.rb Loading Configuration ... Loading Export Data ... Loading Reporting Options ... Completed request for 2a206 on source. Successfully fetched 2a206 from source. Completed request for 2a206 on destination. Successfully created 2a206 on destination. Completed request for 2a206 on source file. Successfully fetched source file called 2a206 form.pdf from 2a206 / source. /home/matt/.rvm/gems/ruby-2.3.5/gems/curb-0.9.4/lib/curl/easy.rb:68: warning: uncaught exception from callback

...and the file is not uploaded on the destination. I get the same thing if I try ruby-2.6.3. The only corresponding log entry is in info.log (nothing in error.log):

Successfully fetched source file called 2a206 form.pdf from 2a206 / source.

aldefouw commented 4 years ago

@senorrojo - Thanks for reporting this. Based on the partial stack trace, the error seems to be happening within the Curl request itself.

Can you see the 2a206 form.pdf file on your hard drive in the ~/redcap-api-transfer/downloaded_files/ folder? How big is the file?

Have you checked the file size limits on the destination server? You might be exceeding the configured PHP max upload size or some other limit ...

This might be hard to reproduce for me if this is a configuration issue at the PHP level on your server. If you want, you could post a phpinfo() of the file upload limits, etc.

senorrojo commented 4 years ago

Ah, that downloaded_files directory did not exist. Just created it and tried again on the single record and all worked. Also tried it with all records on a more complicated project and everything worked as expected. Thanks for the easy (and quick) fix!

aldefouw commented 4 years ago

@senorrojo - You might have uncovered a potential oversight / bug in the script though. It would probably be better if I created that folder if it does not exist.

I probably never noticed it because I always had the folder on my local machine ...

aldefouw commented 4 years ago

Fix will be to investigate whether it's worth creating the /downloaded_files folder.

Probably need to do a change directory and create the folder.

aldefouw commented 4 years ago

@senorrojo - Note that there is now a change to repository that should prevent what you experienced.

https://github.com/aldefouw/redcap-api-transfer/commit/1a7593a375bff74b61503a2d70a4d3e4d5eddddf

What I'm doing now is detecting if the /downloaded_files folder exists. If it does not, I create it. That should prevent the error you were experiencing.

If you want to pull the patch, remove that folder and see if it works that would be cool. Thanks!

senorrojo commented 4 years ago

@aldefouw Just pulled the patch, removed the folder and did a test transfer - the directory was auto-created on transfer and all worked as expected with no errors. Confirming that the patch works. Thanks!

aldefouw commented 4 years ago

@senorrojo - Awesome thanks for confirming.