Beispiel #1
0
    def download(self, path, version=None, revision=None, mode=None, **kwargs):
        if not path.identifier:
            raise exceptions.NotFoundError(str(path))

        if version is None:
            # TODO Clean this up
            # version could be 0 here
            version = revision

        # osf storage metadata will return a virtual path within the provider
        resp = yield from self.make_signed_request(
            'GET',
            self.build_url(path.identifier, 'download', version=version, mode=mode),
            expects=(200, ),
            throws=exceptions.DownloadError,
        )

        data = yield from resp.json()
        provider = self.make_provider(data['settings'])
        name = data['data'].pop('name')
        data['data']['path'] = yield from provider.validate_path('/' + data['data']['path'])
        download_kwargs = {}
        download_kwargs.update(kwargs)
        download_kwargs.update(data['data'])
        download_kwargs['displayName'] = kwargs.get('displayName', name)
        return (yield from provider.download(**download_kwargs))
Beispiel #2
0
    def download(self, path, **kwargs):
        if path.identifier is None:
            raise exceptions.NotFoundError(str(path))

        provider = yield from self._make_article_provider(
            path.parts[1].identifier)
        return (yield from provider.download(path, **kwargs))
Beispiel #3
0
    def download(self, path, version=None, revision=None, mode=None, **kwargs):
        if not path.identifier:
            raise exceptions.NotFoundError(str(path))

        if version is None:
            # TODO Clean this up
            # version could be 0 here
            version = revision

        # osf storage metadata will return a virtual path within the provider
        resp = yield from self.make_signed_request(
            'GET',
            self.build_url(path.identifier, 'download', version=version, mode=mode),
            expects=(200, ),
            throws=exceptions.DownloadError,
        )

        data = yield from resp.json()
        provider = self.make_provider(data['settings'])
        name = data['data'].pop('name')
        data['data']['path'] = yield from provider.validate_path('/' + data['data']['path'])
        download_kwargs = {}
        download_kwargs.update(kwargs)
        download_kwargs.update(data['data'])
        download_kwargs['displayName'] = kwargs.get('displayName', name)
        return (yield from provider.download(**download_kwargs))
Beispiel #4
0
    def download(self, **kwargs):
        kwargs['path'] = OSFPath(kwargs['path']).path[1:]

        # osf storage metadata will return a virtual path within the provider
        resp = yield from self.make_signed_request(
            'GET',
            self.callback_url,
            params=kwargs,
            expects=(200, ),
            throws=exceptions.DownloadError,
        )

        kwargs.pop('version', None)

        data = yield from resp.json()
        provider = self.make_provider(data['settings'])
        data['data']['path'] = '/' + data['data']['path']
        download_kwargs = {}
        download_kwargs.update(kwargs)
        download_kwargs.update(data['data'])
        download_kwargs['displayName'] = kwargs.get('displayName') or kwargs['path']
        return (yield from provider.download(**download_kwargs))
Beispiel #5
0
    def download(self, path, **kwargs):
        if path.identifier is None:
            raise exceptions.NotFoundError(str(path))

        provider = yield from self._make_article_provider(path.parts[1].identifier)
        return (yield from provider.download(path, **kwargs))
Beispiel #6
0
 def download(self, path, **kwargs):
     figshare_path = FigshareProjectPath(path)
     provider = yield from self._make_article_provider(figshare_path.article_id)
     return (yield from provider.download(str(figshare_path.child), **kwargs))
Beispiel #7
0
 def download(self, path, **kwargs):
     provider = yield from self._make_article_provider(path.parts[1].identifier)
     return (yield from provider.download(path, **kwargs))