当前位置: 首页>>代码示例>>Python>>正文


Python File.save方法代码示例

本文整理汇总了Python中leancloud.File.save方法的典型用法代码示例。如果您正苦于以下问题:Python File.save方法的具体用法?Python File.save怎么用?Python File.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在leancloud.File的用法示例。


在下文中一共展示了File.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_destroy

# 需要导入模块: from leancloud import File [as 别名]
# 或者: from leancloud.File import save [as 别名]
def test_destroy():
    r = requests.get('http://i1.wp.com/leancloud.cn/images/static/default-avatar.png')
    b = buffer(r.content)
    f = File('Lenna2.jpg', b)
    f.save()
    assert f.id
    f.destroy()
开发者ID:lord63-forks,项目名称:python-sdk,代码行数:9,代码来源:test_file.py

示例2: test_destroy

# 需要导入模块: from leancloud import File [as 别名]
# 或者: from leancloud.File import save [as 别名]
def test_destroy():  # type: () -> None
    r = requests.get('http://i1.wp.com/leancloud.cn/images/static/default-avatar.png')
    b = io.BytesIO(r.content)
    f = File('Lenna2.jpg', b)
    f.save()
    assert f.id
    f.destroy()
开发者ID:leancloud,项目名称:python-sdk,代码行数:9,代码来源:test_file.py

示例3: test_thumbnail

# 需要导入模块: from leancloud import File [as 别名]
# 或者: from leancloud.File import save [as 别名]
def test_thumbnail():
    r = requests.get('http://www.lenna.org/full/len_std.jpg')
    f = File('Lenna2.jpg', r.content)
    f.save()
    assert f.id

    url = f.get_thumbnail_url(100, 100)
    assert url.endswith('?imageView/2/w/100/h/100/q/100/format/png')
开发者ID:gokure,项目名称:python-sdk,代码行数:10,代码来源:test_file.py

示例4: test_thumbnail_size_erorr

# 需要导入模块: from leancloud import File [as 别名]
# 或者: from leancloud.File import save [as 别名]
def test_thumbnail_size_erorr():
    r = requests.get('http://www.lenna.org/full/len_std.jpg')
    f = File('Lenna2.jpg', r.content)
    f.save()
    assert f.id

    f.get_thumbnail_url(-1, -1)
    f.get_thumbnail_url(1, 1, quality=110)
开发者ID:gokure,项目名称:python-sdk,代码行数:10,代码来源:test_file.py

示例5: test_thumbnail_size_erorr

# 需要导入模块: from leancloud import File [as 别名]
# 或者: from leancloud.File import save [as 别名]
def test_thumbnail_size_erorr():
    r = requests.get('http://i1.wp.com/leancloud.cn/images/static/default-avatar.png')
    b = buffer(r.content)
    f = File('Lenna2.jpg', b)
    f.save()
    assert f.id

    f.get_thumbnail_url(-1, -1)
    f.get_thumbnail_url(1, 1, quality=110)
开发者ID:lord63-forks,项目名称:python-sdk,代码行数:11,代码来源:test_file.py

示例6: test_thumbnail

# 需要导入模块: from leancloud import File [as 别名]
# 或者: from leancloud.File import save [as 别名]
def test_thumbnail():
    r = requests.get('http://i1.wp.com/leancloud.cn/images/static/default-avatar.png')
    b = buffer(r.content)
    f = File('Lenna2.jpg', b)
    f.save()
    assert f.id

    url = f.get_thumbnail_url(100, 100)
    assert url.endswith('?imageView/2/w/100/h/100/q/100/format/png')
开发者ID:lord63-forks,项目名称:python-sdk,代码行数:11,代码来源:test_file.py

示例7: get_img

# 需要导入模块: from leancloud import File [as 别名]
# 或者: from leancloud.File import save [as 别名]
def get_img(url):
    try:
        fn = url.split('/')[-1]
        c = urllib2.urlopen(url).read()
        f = StringIO(c)
        lc_file = File(fn, f)
        lc_file.save()
        r = lc_file.url
    except Exception, e:
        print '---------', e
        r = None
开发者ID:txdywy,项目名称:airbb,代码行数:13,代码来源:lc_img.py

示例8: test_save

# 需要导入模块: from leancloud import File [as 别名]
# 或者: from leancloud.File import save [as 别名]
def test_save():  # type: () -> None
    user = leancloud.User()
    user.login('user1_name', 'password')

    f = File('Blah.txt', open('tests/sample_text.txt', 'rb'))
    f.save()

    assert f.owner_id == user.id
    assert f.id
    assert f.name == 'Blah.txt'
    assert f.mime_type == 'text/plain'
    assert not f.url.endswith('.')
开发者ID:leancloud,项目名称:python-sdk,代码行数:14,代码来源:test_file.py

示例9: test_file_callback

# 需要导入模块: from leancloud import File [as 别名]
# 或者: from leancloud.File import save [as 别名]
def test_file_callback():  # type: () -> None
    d = {}

    def noop(token, *args, **kwargs):
        d['token'] = token

    f = File('xxx', io.BytesIO(b'xxx'))
    f._save_to_s3 = noop
    f._save_to_qiniu = noop
    f._save_to_qcloud = noop
    f.save()
    f._save_callback(d['token'], False)
开发者ID:leancloud,项目名称:python-sdk,代码行数:14,代码来源:test_file.py

示例10: upload_file

# 需要导入模块: from leancloud import File [as 别名]
# 或者: from leancloud.File import save [as 别名]
 def upload_file(self, file_abspath):
     filename = os.path.basename(file_abspath)    # filename have suffix
     with open(file_abspath, 'r') as f:
         upload_file = File(filename, f)
         upload_file.save()
         print 'uploaded', file_abspath
         img_file = self._class()
         img_file.set('File', upload_file)
         img_file.set('filename', filename)
         tag_list = LeanCloudApi.get_tag_list(filename)
         img_file.set('tag_list', tag_list)
         img_file.save()
         self.add_img_info(img_file.id)    # save img_info after save
开发者ID:00nanhai,项目名称:picwall,代码行数:15,代码来源:leancloud_api.py

示例11: test_fetch

# 需要导入模块: from leancloud import File [as 别名]
# 或者: from leancloud.File import save [as 别名]
def test_fetch():
    r = requests.get('http://i1.wp.com/leancloud.cn/images/static/default-avatar.png')
    b = buffer(r.content)
    f = File('Lenna2.jpg', b)
    f.metadata['foo'] = 'bar'
    f.save()
    fetched = File.create_without_data(f.id)
    fetched.fetch()
    assert fetched.id == f.id
    assert fetched.metadata == f.metadata
    assert fetched.name == f.name
    assert fetched.url == f.url
    assert fetched.size == f.size
    assert fetched.url == f.url
    f.destroy()
开发者ID:lord63-forks,项目名称:python-sdk,代码行数:17,代码来源:test_file.py

示例12: upload

# 需要导入模块: from leancloud import File [as 别名]
# 或者: from leancloud.File import save [as 别名]
def upload(file_path):
    print 'uploading file %s' % file_path
    img_name = path.split(file_path)[1]
    img_file = open(file_path)
    up_file = File(img_name, img_file)
    img_url = up_file.save().url
    return img_url
开发者ID:brucezz,项目名称:WriteMarkdownLazily,代码行数:9,代码来源:lzmd.py

示例13: test_fetch

# 需要导入模块: from leancloud import File [as 别名]
# 或者: from leancloud.File import save [as 别名]
def test_fetch():  # type: () -> None
    r = requests.get('http://i1.wp.com/leancloud.cn/images/static/default-avatar.png')
    b = io.BytesIO(r.content)
    f = File('Lenna2.jpg', b)
    f.metadata['foo'] = 'bar'
    f.save()
    fetched = File.create_without_data(f.id)
    fetched.fetch()

    normalized_f_url = f.url.split('/')[-1]
    normalized_fetched_url = f.url.split('/')[-1]

    assert fetched.id == f.id
    assert fetched.metadata == f.metadata
    assert fetched.name == f.name
    assert fetched.size == f.size
    assert fetched.url == f.url or normalized_fetched_url == normalized_f_url
    f.destroy()
开发者ID:leancloud,项目名称:python-sdk,代码行数:20,代码来源:test_file.py

示例14: upload

# 需要导入模块: from leancloud import File [as 别名]
# 或者: from leancloud.File import save [as 别名]
def upload(file_path):
    cmp_file_path = dirpath + file_path
    if os.path.exists(cmp_file_path):
        img_name = os.path.split(cmp_file_path)[1]
        img_file = open(cmp_file_path)
        up_file = File(img_name, img_file)
        img_url = up_file.save().url
        # print(" url: %s" % img_url)
        return img_url
开发者ID:chocoluffy,项目名称:lazy-screen-capture,代码行数:11,代码来源:replaceClip.py

示例15: post

# 需要导入模块: from leancloud import File [as 别名]
# 或者: from leancloud.File import save [as 别名]
 def post(self, username):
     profile_fields = ['realName', 'gender', 'school', 'grade', 'major', 'about']
     userProfile = Query(UserProfile).equal_to("user", username).first()
     try:
         for key in profile_fields:
             userProfile.set(key, self.get_argument(key, ""))
             if 'file' in self.request.files:
                 file_dict_list = self.request.files['file']
                 for file_dict in file_dict_list:
                     data = file_dict["body"]
                     avatar = File("avatar", buffer(data))
                     avatar.save()
             userProfile.set("avatar", avatar.get_thumbnail_url(width='200', height='200'))
             userProfile.save()
             self.redirect('/user/'+username)
             print self.request
     except LeanCloudError, e:
         pass
开发者ID:LiuYiLe,项目名称:iclass,代码行数:20,代码来源:profile.py


注:本文中的leancloud.File.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。