File Ingest Issues

I'm creating a plugin that uses the insert_files_for_item() function. I think I'm passing in all parameters correctly:
insert_files_for_item($created, 'Url', array($url->loc)), but I keep getting the following error importing items from ContentDM:

Omeka_File_Ingest_Exception

Could not transfer the file from "http://dc.lib.unc.edu/utils/getfile/collection/sohp/id/16997/filename/17039.mp3"
to "/var/folders/5d/10pj_hmn1dnf2klj99tgd7xrnm42t5/T/8098854c7f7d72866229dc0c2999555c.mp3": Passed parameter is not a valid HTTP URI.

The dc.lib.unc.edu path is valid as using Curl or visiting the link directly works as expected and downloads the file.

Thanks,

Dean

I tried out your example URI against Zend Framework's URI component, and it accepted it just fine. Are you sure there aren't any rogue whitespace characters or special characters floating around in $url->loc?

Well, throwing a trim() around the url seemed to do the trick. Interesting, as the url is coming directly from an XML file. I'll have to check the markup.

Thanks,

Dean