Exporting a resource to a file