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


TypeScript graceful-fs.createWriteStream函数代码示例

本文整理汇总了TypeScript中graceful-fs.createWriteStream函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createWriteStream函数的具体用法?TypeScript createWriteStream怎么用?TypeScript createWriteStream使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: function

    return new Promise<string>((resolve, reject) => {
        
        let zipFileName = "geoserver_" + requestTimestamp.toString() + ".zip";
        let zipFilePath = config.get("save_path") + zipFileName;
        let zipStream = fs.createWriteStream(zipFilePath);
        let archive = archiver.create("zip", {});

        zipStream.on("close", function() {
            resolve(zipFileName);
        });
        
        archive.on("error", (err: any) => {
            reject(err);
        });
        
        archive.pipe(zipStream);

        for (let fileName of filesToZip) {
            let fileNameWithoutTimestamp = fileName.replace(/[0-9]/g, "");
            let fn = config.get("save_path") + fileName;
            archive.append(fs.createReadStream(fn), { name: fileNameWithoutTimestamp });
            fs.unlink(fn, (err: any) => {
                if (err) throw err;
            });
            
        }
        
        archive.finalize();        
                
                
    });
开发者ID:usa-npn,项目名称:pop-service,代码行数:31,代码来源:zipBuilder.ts

示例2:

app.get("/pop/fgdc", (req, res) => {
    console.log("get /dot/fgdc");
    let filePath = config.get("metadata_path") + "USA-NPN_Phenology_observation_data.xml";
    let file = fs.createWriteStream(filePath);
    let gitUrl = "https://raw.githubusercontent.com/usa-npn/metadata/master/USA-NPN_Phenology_observation_data.xml";
    https.get(gitUrl, (gitResponse: any) => {
        gitResponse.pipe(file);
        file.on("finish", () => {
            res.download(filePath, "USA-NPN_Phenology_observation_data.xml"); // Set disposition and send it.
        });
    });
});
开发者ID:usa-npn,项目名称:pop-service,代码行数:12,代码来源:server.ts

示例3: resolve

    return new Promise<string>( (resolve, reject) => {
        let fileName = prefix + requestTimestamp + "." + extension;
        let filePath = config.get("save_path") + fileName;
        let file = fs.createWriteStream(filePath);


        https.get(url, (metaResponse: any) => {
            metaResponse.pipe(file);

            metaResponse.on('end', () => {
               resolve(fileName); 
            });
        });   
    });
开发者ID:usa-npn,项目名称:pop-service,代码行数:14,代码来源:server.ts

示例4: if

    return new Promise<string>((resolve, reject) => {
        let zipFileName = "datasheet_" + requestTimestamp.toString() + ".zip";
        let zipFilePath = config.get("save_path") + zipFileName;
        let zipStream = fs.createWriteStream(zipFilePath);
        let archive = archiver.create("zip", {});

        zipStream.on("close", function() {
            console.log("All files are zipped!");
            resolve(zipFileName);
        });

        archive.on("error", (err: any) => {
            reject(err);
        });

        archive.pipe(zipStream);

        for (let fileName of filesToZip) {
            let fileNameWithoutTimestamp = fileName.replace(/[0-9]/g, "");
            archive.append(fs.createReadStream(config.get("save_path") + fileName), { name: fileNameWithoutTimestamp });
        }
        
        if (downloadType === "Status and Intensity" && fs.existsSync(config.get("metadata_path") + "status_intensity_datafield_descriptions.xlsx")) {
            archive.append(fs.createReadStream(config.get("metadata_path") + "status_intensity_datafield_descriptions.xlsx"), { name: "status_intensity_datafield_descriptions.xlsx" });
        }
        else if (downloadType === "Site Phenometrics" && fs.existsSync(config.get("metadata_path") + "site_phenometrics_datafield_descriptions.xlsx")) {
            archive.append(fs.createReadStream(config.get("metadata_path") + "site_phenometrics_datafield_descriptions.xlsx"), { name: "site_phenometrics_datafield_descriptions.xlsx" });
        }
        else if (downloadType === "Individual Phenometrics" && fs.existsSync(config.get("metadata_path") + "individual_phenometrics_datafield_descriptions.xlsx")) {
            archive.append(fs.createReadStream(config.get("metadata_path") + "individual_phenometrics_datafield_descriptions.xlsx"), { name: "individual_phenometrics_datafield_descriptions.xlsx" });
        }else if (downloadType === "Magnitude Phenometrics" && fs.existsSync(config.get("metadata_path") + "magnitude_phenometrics_datafield_descriptions.xlsx")) {
            archive.append(fs.createReadStream(config.get("metadata_path") + "magnitude_phenometrics_datafield_descriptions.xlsx"), { name: "magnitude_phenometrics_datafield_descriptions.xlsx" });
        }
        
        if (filesToZip.length > 2 && fs.existsSync(config.get("metadata_path") + "ancillary_datafield_descriptions.xlsx")) {
            archive.append(fs.createReadStream(config.get("metadata_path") + "ancillary_datafield_descriptions.xlsx"), { name: "ancillary_datafield_descriptions.xlsx" });
        }
        archive.finalize();
    });
开发者ID:usa-npn,项目名称:pop-service,代码行数:39,代码来源:zipBuilder.ts

示例5: express

let pool      =    mysql.createPool({
    connectionLimit : 20,
    host     : config.get("mysql_host") as string,
    user     : config.get("mysql_user") as string,
    password : config.get("mysql_password") as string,
    database : config.get("mysql_database") as string,
    debug    :  false
});

let app = express();

// allows us to consume json from post requests
app.use(bodyParser.json());

// create a write stream (in append mode) and set up a log to record requests
let accessLogStream = fs.createWriteStream(path.join(config.get("logs_path").toString(), "access.log"), {flags: "a"});
app.use(morgan("combined", {stream: accessLogStream}));

let log = bunyan.createLogger({
    name: "dot_service",
    streams: [
        {
            level: "info",
            path: path.join(config.get("logs_path").toString(), "info.log")
        },
        {
            level: "error",
            path: path.join(config.get("logs_path").toString(), "error.log")
        }
    ]
});
开发者ID:usa-npn,项目名称:pop-service,代码行数:31,代码来源:server.ts


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