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


Python UploadSet.save方法代码示例

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


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

示例1: test_secured_filename

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import save [as 别名]
 def test_secured_filename(self):
     uset = UploadSet('files', ALL)
     uset._config = Config('/uploads')
     tfs1 = TestingFileStorage(filename='/etc/passwd')
     tfs2 = TestingFileStorage(filename='../../myapp.wsgi')
     res1 = uset.save(tfs1)
     assert res1 == 'etc_passwd'
     assert tfs1.saved == '/uploads/etc_passwd'
     res2 = uset.save(tfs2)
     assert res2 == 'myapp.wsgi'
     assert tfs2.saved == '/uploads/myapp.wsgi'
开发者ID:franciscogodoy,项目名称:flask-appengine-template,代码行数:13,代码来源:test-uploads.py

示例2: upload_photo

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import save [as 别名]
def upload_photo(file_data, path, filename):
    """Uploads a photo to storage."""
    photo_set = UploadSet('photos', IMAGES)
    if photo_set:
        # Create the thumbnail and preview
        thumb = create_thumbnail(file_data.stream, THUMB_SIZE)
        preview = create_thumbnail(file_data.stream, PREVIEW_SIZE)

        # Save the full size picture and the thumbnail and preview
        try:
            photo_set.save(file_data, path, filename)
            save_image(thumb, path, 'thumb_' + filename)
            save_image(preview, path, 'preview_' + filename)
        except Exception, ex:
            raise ex
开发者ID:eightytwo,项目名称:collectables,代码行数:17,代码来源:general.py

示例3: test_conflict

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import save [as 别名]
 def test_conflict(self):
     uset = UploadSet('files')
     uset._config = Config('/uploads')
     tfs = TestingFileStorage(filename='foo.txt')
     self.extant('/uploads/foo.txt')
     res = uset.save(tfs)
     assert res == 'foo_1.txt'
开发者ID:franciscogodoy,项目名称:flask-appengine-template,代码行数:9,代码来源:test-uploads.py

示例4: test_implicit_folder

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import save [as 别名]
 def test_implicit_folder(self):
     uset = UploadSet('files')
     uset._config = Config('/uploads')
     tfs = TestingFileStorage(filename='boat.jpg')
     res = uset.save(tfs, name='someguy/photo_123.')
     assert res == 'someguy/photo_123.jpg'
     assert tfs.saved == '/uploads/someguy/photo_123.jpg'
开发者ID:franciscogodoy,项目名称:flask-appengine-template,代码行数:9,代码来源:test-uploads.py

示例5: test_save_namedext

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import save [as 别名]
 def test_save_namedext(self):
     uset = UploadSet('files')
     uset._config = Config('/uploads')
     tfs = TestingFileStorage(filename='boat.jpg')
     res = uset.save(tfs, name='photo_123.')
     assert res == 'photo_123.jpg'
     assert tfs.saved == '/uploads/photo_123.jpg'
开发者ID:franciscogodoy,项目名称:flask-appengine-template,代码行数:9,代码来源:test-uploads.py

示例6: test_save_named

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import save [as 别名]
 def test_save_named(self):
     uset = UploadSet('files')
     uset._config = Config('/uploads')
     tfs = TestingFileStorage(filename='foo.txt')
     res = uset.save(tfs, name='file_123.txt')
     assert res == 'file_123.txt'
     assert tfs.saved == '/uploads/file_123.txt'
开发者ID:franciscogodoy,项目名称:flask-appengine-template,代码行数:9,代码来源:test-uploads.py

示例7: test_save_folders

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import save [as 别名]
 def test_save_folders(self):
     uset = UploadSet('files')
     uset._config = Config('/uploads')
     tfs = TestingFileStorage(filename='foo.txt')
     res = uset.save(tfs, folder='someguy')
     assert res == 'someguy/foo.txt'
     assert tfs.saved == '/uploads/someguy/foo.txt'
开发者ID:franciscogodoy,项目名称:flask-appengine-template,代码行数:9,代码来源:test-uploads.py

示例8: test_multi_conflict

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import save [as 别名]
 def test_multi_conflict(self):
     uset = UploadSet('files')
     uset._config = Config('/uploads')
     tfs = TestingFileStorage(filename='foo.txt')
     self.extant('/uploads/foo.txt',
                 *('/uploads/foo_%d.txt' % n for n in range(1, 6)))
     res = uset.save(tfs)
     assert res == 'foo_6.txt'
开发者ID:franciscogodoy,项目名称:flask-appengine-template,代码行数:10,代码来源:test-uploads.py

示例9: test_conflict_without_extension

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import save [as 别名]
 def test_conflict_without_extension(self):
     # Test case for issue #7.
     uset = UploadSet('files', extensions=(''))
     uset._config = Config('/uploads')
     tfs = TestingFileStorage(filename='foo')
     self.extant('/uploads/foo')
     res = uset.save(tfs)
     assert res == 'foo_1'
开发者ID:bcb,项目名称:flask-uploads,代码行数:10,代码来源:test-uploads.py

示例10: upload

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import save [as 别名]
def upload():
    images = UploadSet('images', IMAGES)
    logging.info(request)

    if request.method == 'POST' and 'image_1' and 'image_2' in request.files:
        filename_1 = images.save(app.config['UPLOAD'], request.files['image_1'])
        filename_2 = images.save(app.config['UPLOAD'], request.files['image_2'])
        rec = Photo(filename=filename, user=g.user.id)
        rec.store()
        flash("Photo saved.")
        return "OK", 204

    return "Failed", 404
开发者ID:NadyaMansurova,项目名称:piv-d3,代码行数:15,代码来源:run.py


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