Esempio n. 1
0
    def up_to_upyun(self, collection, data, img_name):

        bucket = UpyunConfig.BUCKET
        admin = UpyunConfig.ADMIN
        password = UpyunConfig.PASSWORD

        u = UpYun(bucket, admin, password)
        u.setApiDomain('v0.api.upyun.com')
        #TODO u.setContentMD5(md5file(data))

        # save file
        year = datetime.datetime.now().strftime("%Y")
        month = datetime.datetime.now().strftime("%m")
        day = datetime.datetime.now().strftime("%d")
        target = '/%s/%s/%s/%s/%s' % (collection, year, month, day, img_name)

        a = u.writeFile(str(target) , data.read(), True)
        url = UpyunConfig.URL + str(target)
        return url
Esempio n. 2
0
    def up_to_upyun(self, collection, data, img_name):

        bucket = UpyunConfig.BUCKET
        admin = UpyunConfig.ADMIN
        password = UpyunConfig.PASSWORD

        u = UpYun(bucket, admin, password)
        u.setApiDomain('v0.api.upyun.com')
        # TODO u.setContentMD5(md5file(data))

        # save file
        year = datetime.datetime.now().strftime("%Y")
        month = datetime.datetime.now().strftime("%m")
        day = datetime.datetime.now().strftime("%d")
        target = '/%s/%s/%s/%s/%s' % (collection, year, month, day, img_name)

        a = u.writeFile(str(target), data.read(), True)
        url = UpyunConfig.URL + str(target)
        return url
Esempio n. 3
0
    def up_to_upyun(self, collection, data, img_name):
        """Method to upload single image to upyun.

        Args:
            collection: string collection name
            data: image file data
            img_name: string image name, not hashed before

        Return:
            url: like 'http://v0.api.upyun.com/collection1/2013/07/01/abc.jpg'
        """
        bucket = UpyunConfig.BUCKET
        admin = UpyunConfig.ADMIN
        password = UpyunConfig.PASSWORD

        u = UpYun(bucket, admin, password)
        u.setApiDomain('v0.api.upyun.com')
        # TODO u.setContentMD5(md5file(data))

        # save file
        year = datetime.datetime.now().strftime("%Y")
        month = datetime.datetime.now().strftime("%m")
        day = datetime.datetime.now().strftime("%d")
        target = '/%s/%s/%s/%s/%s' % (collection, year, month, day, img_name)

        u.writeFile(str(target), data.read(), True)
        url = UpyunConfig.URL + str(target)
        return url