def send_file(self, file_id, abs_directory_path): socket = self.request abs_file_path = os.path.join(abs_directory_path, file_id) f = open(abs_file_path, 'r') bytes_size = os.path.getsize(abs_file_path) local_file = LocalFile(f, file_id, abs_file_path, bytes_size) send_file_from_local_to_remote(local_file, socket) local_file.close()
def store_file(self, file_id, file_size): socket = self.request send_confirmation_message_to_upload_request(file_id, file_size, socket) file_contents = download_file(file_id, file_size, socket) logging.info("Storing file: " + file_id) abs_file_path = os.path.join(abs_directory_path, file_id) f = open(abs_file_path, 'w+') f.write(file_contents) bytes_size = os.path.getsize(abs_file_path) local_file = LocalFile(f, file_id, abs_file_path, bytes_size) local_file.close() logging.info("Storing file finished: " + file_id)