static void Main(string[] args) { Options options = new Options(); if (CommandLine.Parser.Default.ParseArguments(args, options)) { QiniuConfig conf = new QiniuConfig("Wege4i-gz1IyWpCEfjhfEjZDj9U7IAhCXwq5FzxP", "l9DlUgST1KhGInpA--QMqeY3sLmaQ6nBCp_HOpH9", "7xosys.com1.z0.glb.clouddn.com", "notebook"); QiniuFile qiniu = new QiniuFile(conf, "D:/"); qiniu.init(); try { // 创建文件 FileStream fs = new FileStream("uploadtest", FileMode.OpenOrCreate, FileAccess.ReadWrite); StreamWriter sw = new StreamWriter(fs); sw.WriteLine("uploadtest"); sw.Close(); qiniu.Upload("uploadtest", true); File.Delete("uploadtest"); } catch (Exception e) { if (File.Exists("uploadtest")) File.Delete("uploadtest"); return; } Console.WriteLine(options.SaveDir); } else { ; } }
public void UploadTest() { QiniuConfig conf = m_good_conf; QiniuFile qiniu = new QiniuFile(conf, "."); qiniu.init(); Upload_FileNotExists(qiniu); return; }
public void DownloadTest() { QiniuConfig conf = m_good_conf; QiniuFile qiniu = new QiniuFile(conf, "."); qiniu.init(); Download_None(qiniu); Download_NotExists(qiniu); Download_UrlError(); Download_Accesskey_Error(); Download_secretkey_Error(); Download_bucketname_Error(); Download_EmptyDirAndFilename_Error(); return; }
void Download_EmptyDirAndFilename_Error() { string empty_dir = ""; string empty_filename = ""; QiniuConfig conf = new QiniuConfig("Wege4i-gz1IyWpCEfjhfEjZDj9U7IAhCXwq5FzxP", "l9DlUgST1KhGInpA--QMqeY3sLmaQ6nBCp_HOpH9", "7xosys.com1.z0.glb.clouddn.com", "notebook"); QiniuFile qiniu = new QiniuFile(conf, empty_dir); try { qiniu.init(); qiniu.Download(empty_filename); } catch (ArgumentException e) { return; } Assert.Fail("No exception was thrown."); }
void Download_bucketname_Error() { QiniuConfig conf = m_badbucketname_conf; QiniuFile qiniu = new QiniuFile(conf, "D:/"); string file = "/test/"; try { qiniu.init(); qiniu.Download(file); } catch (WebException e) { if (File.Exists(file)) File.Delete(file); return; } if (File.Exists(file)) File.Delete(file); Assert.Fail("No exception was thrown."); }
void Download_secretkey_Error() { QiniuConfig conf = m_badsecretkey_conf; QiniuFile qiniu = new QiniuFile(conf, "."); try { qiniu.init(); qiniu.Download("/test/"); } catch (WebException e) { return; } Assert.Fail("No exception was thrown."); }