Beispiel #1
0
    def onCall(self, filename):
        if not sponge.getVariable("demo.readOnly", False):
            uploaded = "Uploaded"
            uploadDir = "{}/upload/".format(sponge.home)
            file = File(uploadDir + filename)
            streamValue = OutputStreamValue(lambda output: FileUtils.copyFile(file, output)).withHeader(
                u"Content-Disposition", 'attachment; filename="{}"'.format(filename))
            mimeType = Files.probeContentType(file.toPath())
            if mimeType:
                streamValue.withContentType(mimeType)

            return streamValue
Beispiel #2
0
 def save_screenshot(self, filepath):
     tempfile = self.__firefoxDriver.getScreenshotAs(OutputType.FILE)
     FileUtils.copyFile(tempfile, File(filepath))
Beispiel #3
0
 def onCall(self):
     file = "{}/resources/index.html".format(sponge.home)
     return OutputStreamValue(lambda output: FileUtils.copyFile(File(file), output)).withContentType("text/html; charset=\"UTF-8\"")