This utility should allow for easy copying from a local filesystem to
the storage instance.
with file(dest_path, 'wb') as dest_file:
dest_file.write(source_file.read())
+ def copy_local_to_storage(self, filename, filepath):
+ """
+ Copy this file from locally to the storage system.
+ """
+ with self.get_file(filepath, 'wb') as dest_file:
+ with file(filename, 'rb') as source_file:
+ dest_file.write(source_file.read())
+
###########
# Utilities
NoWebServing)
import os
+import shutil
import urlparse
def get_local_path(self, filepath):
return self._resolve_filepath(filepath)
+
+ def copy_local_to_storage(self, filename, filepath):
+ """
+ Copy this file from locally to the storage system.
+ """
+ # Make directories if necessary
+ if len(filepath) > 1:
+ directory = self._resolve_filepath(filepath[:-1])
+ if not os.path.exists(directory):
+ os.makedirs(directory)
+
+ shutil.copy(
+ filename, self.get_local_path(filepath))