I'm trying to import external nodes from html pages. all working fine but i just cannot make image getting saved in a subfolder.
am mapping a uri value "public://posts/2014/03/4587214.jpg" to "image:uri" and i want the file to be saved in "sites/default/files/posts/2014/03/4587214.jpg" but the file is getting saved in "sites/default/files/posts/4587214.jpg" instead . ("posts" is the value of the subdirectoy in the content type)
any advice on how to make feeds save images in subfolders ? (and create these on fly if do not exist)
i can do it by hacking "feeds/mappers/file.inc" and changing the value of $destination variable as follows:
case 'uri':
if ($v) {
try {
/* patch - start */
/* added to allow subfolder destination */
$uri = $v->getValue();
$uri_target = file_uri_target($uri);
$uri_scheme = file_uri_scheme($uri);
$uri_path_info = pathinfo($uri_target);
$destination = file_stream_wrapper_uri_normalize($uri_scheme . "://" . $uri_path_info['dirname']);
/* patch - end */
$file = $v->getFile($destination);
but i was wandering if this can be done without hacking feeds source files