code: def directory(context, data):
      
      with context.http.rehash(data) as result:
          if not result.ok:
              return
  
          content_hash = data.get('content_hash')
          if content_hash is None:
              context.emit_warning("No content hash in data.")
              return
  
          path = _get_directory_path(context)
          file_name = data.get('file_name', result.file_name)
          file_name = safe_filename(file_name, default='raw')
          file_name = '%s.%s' % (content_hash, file_name)
          data['_file_name'] = file_name
          file_path = os.path.join(path, file_name)
          if not os.path.exists(file_path):
              shutil.copyfile(result.file_path, file_path)
  
          context.log.info("Store [directory]: %s", file_name)
  
          meta_path = os.path.join(path, '%s.json' % content_hash)
          with open(meta_path, 'w') as fh:
              json.dump(data, fh)
docs: Store the collected files to a given directory.