libcurl與ftp構建小檔案傳輸服務

來源:互聯網
上載者:User

標籤:

敬請參見獨立部落格頁面:http://1.oliverwang.sinaapp.com/?p=40

/*The MIT License (MIT)Copyright (c) <2014> <[email protected]>Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.*/#ifndef FTPCLIENT_H#define FTPCLIENT_H#include "curl/curl.h"#include <string>#include <iostream>#include <fstream>using namespace std;/* represent a ftp file */struct FtpFile {    string filename;          /* Name */    string path;              /* Where to save */    FILE *stream;             /* Stream */};/* File type */typedef enum {    BIN_T = 2,         /* Firmware in *.bin */    HEX_T = 3,         /* Firmware in *.hex */    YAML_T = 4         /* Yaml configuration file */} eFileType;typedef int file_t;    /* File type */class FtpClient{    public:        FtpClient();        virtual ~FtpClient();        void SetFtpAddress(const string &url);                               /* Set the ftp server address, Must call before using */        void SetAuthorityAccount(const string &user, const string &pwr);     /* Set the ftp account */        void SetRelativePath(const string &path_yaml, const string &path_fw);        bool FtpDownloadFile(const string &filename, file_t type);               /* Download a file from server */        bool FtpUploadFile(const string &filename);                              /* Upload a file to the server */        static bool isValidIp(char *ip, int len);        string GetRelativePath(file_t type);        /* For test */        void UnitTest_Get();        void UnitTest_Post();        void UnitTest_Print();    private:        string ftpUrl;            /* Ftp Server Address */        string userName;          /* Ftp Server Account Username */        string passWord;          /* Ftp Server Account Password */        string relativePathYaml;  /* file save yaml */        string relativePathFw;    /* file save bin */        static size_t yaml_fwrite(void *buf, size_t _size, size_t nmemb, void *stream);};#endif // FTPCLIENT_H

 

libcurl與ftp構建小檔案傳輸服務

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.