Here at AUT University we're working on a utility which copies files from the learning system into the CMS & relinks them (an enhancement of the "Copy Files to Collection" feature in Blackboard). To do the copy we are using a FileInputStream object and passing it the physical path of the original file:
CSFile cmsFile = ctx.createFile(newlocn,filename,new FileInputStream(oldlocation));
This is fine except that when a filename contains spaces, the physical file becomes a long string of numbers/letters eg:
[root@cepd embedded]# ls -l /usr/local/blackboard//content/vi/bb_bb60/courses/1/assess2_2009_02/content/_1581_1/embedded/total 5704-rw-r--r-- 1 bbuser bbuser 1927176 Jan 15 09:08 !46726f6d2043616d657261203134204a616e20303031.jpg-rw-r--r-- 1 bbuser bbuser 1979128 Jan 15 09:08 !46726f6d2043616d657261203134204a616e20303032.jpg-rw-r--r-- 1 bbuser bbuser 1913750 Jan 15 09:08 !46726f6d2043616d657261203134204a616e20303033.jpg
Our question is, how can we tell which of these files is which? A regular attached file has a size property that we can access from its ContentFile object, and we can check this against the size of the physical file in Linux. If the file is embedded in the wysiwyg I'm not sure how we can access it's size property, so we're back at square one again: which of these files is which...
Steve Lord
See blackboard.util.FileUtil - pay particular attention to the encodeFileName and findEncodedFileName methods.
Files with spaces, multibyte characters are hex encoded. Remove the leading ! and hex decode the "46726f6d2043616d657261203134204a616e20303031" to recover the original name "From Camera 14 Jan 001"