Exemple #1
0
    def test_imageView(self):
        iv = fop.ImageView()
        iv.height = 100
        ret = iv.make_request(pic)
        self.assertEqual(ret, "%s?imageView/1/h/100" % pic)

        iv.quality = 20
        iv.format = "png"
        ret = iv.make_request(pic)
        self.assertEqual(ret, "%s?imageView/1/h/100/q/20/format/png" % pic)
Exemple #2
0
    def save_file_qiniu(binary, filename, mime="application/octet-stream"):

        today = datetime.now().strftime("%Y/%m/%d/")
        filename = today + filename

        policy = rs.PutPolicy(QINIU_SETTINGS.BUCKET_NAME)
        uptoken = policy.token()

        extra = io.PutExtra()
        extra.mime_type = mime

        res, err = io.put(uptoken, filename, binary, extra)
        if err is not None:
            raise Exception("Qiniu save file [%s] error: %s res: %s" % (filename, err, res))

        url = rs.make_base_url(QINIU_SETTINGS.BUCKET_DOMAIN, filename)

        iv = fop.ImageView()
        iv.mode = 2
        iv.width = THUMB_SIZE[0]
        url_thumb = iv.make_request(url)

        return url, url_thumb