Libcurl and FTP to build small file transfer service

Source: Internet
Author: User
Tags ftp file

Please see the standalone blog page: http://1.oliverwang.sinaapp.com/?p=40

/*The MIT License (MIT) Copyright (c) <2014> <[email protected]>permission is hereby granted, free of charge Obtaining a copyof This software and associated documentation files (the "software") to Dealin the Softwa Re without restriction, including without limitation the Rightsto use, copy, modify, merge, publish, distribute, Sublicens E, and/or sellcopies of the software, and to permit persons to whom the software isfurnished to doing so, subject to the Foll Owing conditions:the above copyright notice and this permission notice shall be included inall copies or substantial Porti ONS of the Software.the software is provided ' as is ', without WARRANTY of any KIND, EXPRESS orimplied, including and not L Imited to the warranties of merchantability,fitness for A particular PURPOSE and noninfringement.  In NO EVENT shall theauthors or COPYRIGHT holders is 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 same or other dealings inthe software. */#ifndef Ftpclient_h#defineFtpclient_h#include"curl/curl.h"#include<string>#include<iostream>#include<fstream>using namespacestd;/*represent a ftp file*/structFtpfile {stringFileName/*Name*/    stringPath/*Where to save*/FILE*stream;/*Stream*/};/*File Type*/typedefenum{bin_t=2,/*Firmware in *.bin*/hex_t=3,/*Firmware in *.hex*/yaml_t=4         /*Yaml configuration file*/} efiletype;typedefintfile_t;/*File Type*/classftpclient{ Public: FtpClient (); Virtual~ftpclient (); voidSetftpaddress (Const string&url);/*Set The FTP server address, must call before using*/        voidSetauthorityaccount (Const string&user,Const string&AMP;PWR);/*Set the FTP account*/        voidSetrelativepath (Const string&path_yaml,Const string&PATH_FW); BOOLFtpdownloadfile (Const string&filename, file_t type);/*Download a file from server*/        BOOLFtpuploadfile (Const string&filename);/*Upload A file to the server*/        Static BOOLIsvalidip (Char*ip,intLen); stringGetrelativepath (file_t type); /*For Test*/        voidUnittest_get (); voidUnittest_post (); voidUnittest_print (); Private:        stringFtpurl;/*FTP Server Address*/        stringUserName;/*Ftp Server Account Username*/        stringPassWord;/*Ftp Server Account Password*/        stringRelativepathyaml;/*File Save Yaml*/        stringRELATIVEPATHFW;/*File Save Bin*/        Staticsize_t Yaml_fwrite (void*buf, size_t _size, size_t nmemb,void*stream);};#endif //Ftpclient_h

Libcurl and FTP to build small file transfer service

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.