示例#1
0
    def get(self, request, cu, roleIds = None, fileId = None,
            repos = None, **kwargs):
        sha1, isConfig = repquery.getFileSha1(cu, roleIds, fileId)
        if sha1 is None:
            return response.Response(status=404)

        localPath = repos.repos.contentsStore.hashToPath(sha1)
        bzippedFile = gzip.GzipFile(localPath, "r")
        uncompressedFile = util.BZ2File(bzippedFile)

        return CompressFileResponse(uncompressedFile)
示例#2
0
    def content(self, request, cu, roleIds = None, fileId = None,
                repos = None, **kwargs):
        sha1, isConfig = repquery.getFileSha1(cu, roleIds, fileId)
        if sha1 is None:
            return response.Response(status=404)

        localPath = repos.repos.contentsStore.hashToPath(sha1)
        if request.unparsedPath:
            remotePath = os.path.basename(request.unparsedPath)
        else:
            remotePath = sha1
        return FileResponse(localPath, gzipped=True, remotePath=remotePath,
                download=not isConfig)
示例#3
0
    def get(self,
            request,
            cu,
            roleIds=None,
            fileId=None,
            repos=None,
            **kwargs):
        sha1, isConfig = repquery.getFileSha1(cu, roleIds, fileId)
        if sha1 is None:
            return response.Response(status=404)

        localPath = repos.repos.contentsStore.hashToPath(sha1)
        bzippedFile = gzip.GzipFile(localPath, "r")
        uncompressedFile = util.BZ2File(bzippedFile)

        return CompressFileResponse(uncompressedFile)
示例#4
0
    def content(self,
                request,
                cu,
                roleIds=None,
                fileId=None,
                repos=None,
                **kwargs):
        sha1, isConfig = repquery.getFileSha1(cu, roleIds, fileId)
        if sha1 is None:
            return response.Response(status=404)

        localPath = repos.repos.contentsStore.hashToPath(sha1)
        if request.unparsedPath:
            remotePath = os.path.basename(request.unparsedPath)
        else:
            remotePath = sha1
        return FileResponse(localPath,
                            gzipped=True,
                            remotePath=remotePath,
                            download=not isConfig)