def copy(self, file_id, dest_resource, dest_file_id, **kwargs): # can only transfer out of box from designsafe.apps.api.data import lookup_transfer_service service = lookup_transfer_service(self.resource, dest_resource) if service: args = (self._user.username, self.resource, file_id, dest_resource, dest_file_id) service.apply_async(args=args) return {'message': 'The requested transfer has been scheduled'} else: message = 'The requested transfer from %s to %s ' \ 'is not supported' % (self.resource, dest_resource) extra = {'file_id': file_id, 'dest_resource': dest_resource, 'dest_file_id': dest_file_id} raise ApiException(message, status=400, extra=extra)
def copy(self, file_id, dest_resource, dest_file_id, **kwargs): # can only transfer out of box from designsafe.apps.api.data import lookup_transfer_service service = lookup_transfer_service(self.resource, dest_resource) if service: args = (self._user.username, self.resource, file_id, dest_resource, dest_file_id) service.apply_async(args=args, queue='files') return {'message': 'The requested transfer has been scheduled'} else: message = 'The requested transfer from %s to %s ' \ 'is not supported' % (self.resource, dest_resource) extra = { 'file_id': file_id, 'dest_resource': dest_resource, 'dest_file_id': dest_file_id } raise ApiException(message, status=400, extra=extra)
def copy(self, file_id, dest_resource, dest_file_id, **kwargs): """Copies a file Copies a file in both the Agave filesystem and the Elasticsearch index. :param str file_id: :param str dest_resource: :param str dest_file_id: :returns: dict representation of the original :class:`designsafe.apps.api.data.agve.file.AgaveFile` instance :rtype: dict Examples: -------- Copy a file. `fm` is an instance of FileManager >>> fm.copy(file_id='designsafe.storage.default/username/file.jpg', >>> dest_resource='agave', >>> dest_file_id='designsafe.storage.default/username/file_copy.jpg') """ if self._user.is_anonymous(): raise ApiException( message='You must log in to perform this action.', status=403) # can only transfer out of public from designsafe.apps.api.data import lookup_transfer_service service = lookup_transfer_service(self.resource, dest_resource) if service: args = (self.username, self.resource, file_id, dest_resource, dest_file_id) service.apply_async(args=args, queue='files') return {'message': 'The requested transfer has been scheduled'} else: message = 'The requested transfer from %s to %s ' \ 'is not supported' % (self.resource, dest_resource) extra = { 'file_id': file_id, 'dest_resource': dest_resource, 'dest_file_id': dest_file_id } raise ApiException(message, status=400, extra=extra)
def copy(self, file_id, dest_resource, dest_file_id, **kwargs): """Copies a file Copies a file in both the Agave filesystem and the Elasticsearch index. :param str file_id: :param str dest_resource: :param str dest_file_id: :returns: dict representation of the original :class:`designsafe.apps.api.data.agve.file.AgaveFile` instance :rtype: dict Examples: -------- Copy a file. `fm` is an instance of FileManager >>> fm.copy(file_id='designsafe.storage.default/username/file.jpg', >>> dest_resource='agave', >>> dest_file_id='designsafe.storage.default/username/file_copy.jpg') """ if self._user.is_anonymous(): raise ApiException(message="You must log in to perform this action.", status=403) # can only transfer out of public from designsafe.apps.api.data import lookup_transfer_service service = lookup_transfer_service(self.resource, dest_resource) if service: args = (self.username, self.resource, file_id, dest_resource, dest_file_id) service.apply_async(args=args) return {"message": "The requested transfer has been scheduled"} else: message = "The requested transfer from %s to %s " "is not supported" % (self.resource, dest_resource) extra = {"file_id": file_id, "dest_resource": dest_resource, "dest_file_id": dest_file_id} raise ApiException(message, status=400, extra=extra)