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


TypeScript knownFolders.documents方法代码示例

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


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

示例1: function

export var test_getContentAsFile = function (done) {
    var result;

    // >> http-get-urlfile-content
    var filePath = fs.path.join(fs.knownFolders.documents().path, "test.png");
    http.getFile("https://httpbin.org/image/png?testQuery=query&anotherParam=param", filePath).then(function (r) {
        //// Argument (r) is File!
        // >> (hide)
        result = r;
        try {
            TKUnit.assert(result instanceof fs.File, "Result from getFile() should be valid File object!");
            done(null);
        }
        catch (err) {
            done(err);
        }
        // << (hide)
    }, function (e) {
        //// Argument (e) is Error!
        // >> (hide)
        done(e);
        // << (hide)
    });
    // << http-get-urlfile-content
};
开发者ID:sitefinitysteve,项目名称:NativeScript,代码行数:25,代码来源:http-tests.ts

示例2: testSaveToFile_WithQuality

export function testSaveToFile_WithQuality() {
    const img = imageSource.fromFile(imagePath);
    const folder = fs.knownFolders.documents();
    const path = fs.path.join(folder.path, "test.png");
    const saved = img.saveToFile(path, "png", 70);
    TKUnit.assert(saved, "Image not saved to file");
    TKUnit.assert(fs.File.exists(path), "Image not saved to file");
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:8,代码来源:image-source-tests.ts

示例3:

 source.fromAsset(imageAsset).then((source) => {
     let folder = fs.knownFolders.documents().path;
     let fileName = "test.png"
     let path = fs.path.join(folder, fileName);
     let saved = source.saveToFile(path, "png");
     if(saved){
        console.log("saved image")
     }
 })
开发者ID:sitefinitysteve,项目名称:NativeScript,代码行数:9,代码来源:image-source-snippet.ts

示例4:

 source.fromAsset(imageAsset).then((imageSource) => {
     let folder = fs.knownFolders.documents().path;
     let fileName = "test.png";
     let path = fs.path.join(folder, fileName);
     let saved = imageSource.saveToFile(path, "png");
     if (saved) {
         console.log("Image saved successfully!");
     }
 })
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:9,代码来源:image-source-snippet.ts

示例5: testSaveToFile

export function testSaveToFile() {
    // >> imagesource-save-to
    const img = imageSource.fromFile(imagePath);
    const folder = fs.knownFolders.documents();
    const path = fs.path.join(folder.path, "test.png");
    const saved = img.saveToFile(path, "png");
    // << imagesource-save-to
    TKUnit.assert(saved, "Image not saved to file");
    TKUnit.assert(fs.File.exists(path), "Image not saved to file");
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:10,代码来源:image-source-tests.ts

示例6: testFromFile

export function testFromFile() {
    // >> imagesource-load-local
    const folder = fs.knownFolders.documents();
    const path = fs.path.join(folder.path, "test.png");
    const img = imageSource.fromFile(path);
    // << imagesource-load-local

    TKUnit.assert(img.height > 0, "image.fromResource failed");

    // remove the image from the file system
    const file = folder.getFile("test.png");
    file.remove();
    TKUnit.assert(!fs.File.exists(path), "test.png not removed");
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:14,代码来源:image-source-tests.ts


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