public async Task <HttpResult <batch> > del(string id) { //token.Instance.refresh_token = "xxxx"; //var r = await token.Instance.refresh(); requests = new List <Type_batch_requests>(); requests.Add(new Type_batch_requests { body = new Type_batch_requests_body { drive_id = token.Instance.default_drive_id, file_id = id, }, headers = new Type_batch_requests_headers { ContentType = "application/json" }, id = id, method = "DELETE", url = "/file/delete" }); var client = new Hclient <batch>(); var r = await client.PostAsJsonAsync(DriveApi.batch, new { requests, resource = "file" }); return(r); }
public async Task <HttpResult <file> > list() { //token.Instance.refresh_token = "xxxx"; //var r = await token.Instance.refresh(); var client = new Hclient <file>(); if (drive_id == null) { drive_id = token.Instance.default_drive_id; } if (parent_file_id == null) { parent_file_id = "root"; } var r = await client.PostAsJsonAsync(DriveApi.file_list, new { limit, marker, drive_id, parent_file_id, image_thumbnail_process, image_url_process, video_thumbnail_process, fields, order_by, order_direction }); return(r); }
public async Task <HttpResult <upload> > put(string url, Stream stream, TaskInfo task) { var client = new Hclient <upload>(); var r = await client.PutAsJsonAsync(url, stream, task); if (r.success) { etag = r.body; } return(r); }
public async Task <HttpResult <info_file> > get() { var client = new Hclient <info_file>(); var r = await client.PostAsJsonAsync(DriveApi.file_create, new { drive_id = token.Instance.default_drive_id, parent_file_id, file_id, fields, type, }); return(r); }
public async Task <HttpResult <upload> > complete() { var client = new Hclient <upload>(); var r = await client.PostAsJsonAsync(DriveApi.file_complete, new { drive_id, file_id, ignoreError, part_info_list = part_info_list.Select(o => new { o.part_number, o.etag }), upload_id, }); return(r); }
public async Task <HttpResult <databox> > get_personal_info(bool redirect = false) { var client = new Hclient <databox>(); var r = await client.PostAsJsonAsync(DriveApi.databox_get_personal_info, new { }); if (r.success) { databox.Instance = r.obj; //databox.Instance.Config_Save();不保存这个了 } else { Console.WriteLine($"获取个人信息失败:{r.Error}"); } return(r); }
public async Task <HttpResult <upload> > share(List <String> file_id_list, string name, TaskInfo task) { var f = this; f.drive_id = token.Instance.default_drive_id; f.file_id = file_id; f.name = name; var client = new Hclient <upload>(); var r = await client.PostAsJsonAsync(DriveApi.file_share, new { drive_id = drive_id, file_id_list = file_id_list, share_pwd = Guid.NewGuid().ToString().Substring(0, 4), expiration = "2030-04-15T17:13:58.720+08:00" }); return(r); }
public async Task <HttpResult <upload> > rename(string file_id, string name, TaskInfo task) { var f = this; f.check_name_mode = "refuse";// ignore, auto_rename, refuse. f.drive_id = token.Instance.default_drive_id; f.file_id = file_id; f.name = name; var client = new Hclient <upload>(); var r = await client.PostAsJsonAsync(DriveApi.file_update, new { name, drive_id, file_id, check_name_mode }); return(r); }
public async Task <HttpResult <upload> > create() { var client = new Hclient <upload>(); var r = await client.PostAsJsonAsync(DriveApi.file_create, new { name, type, content_type, size, drive_id, parent_file_id, part_info_list, content_hash_name, content_hash, ignoreError, check_name_mode }); return(r); }
public async Task <HttpResult <token> > Refresh() { Console.WriteLine($"正在刷新access_token"); var client = new Hclient <token>(); var r = await client.PostAsJsonAsync(DriveApi.token_refresh, new { refresh_token }, null, true); if (r.success) { Console.WriteLine($"获取access_token成功"); Instance = r.obj; Instance.Config_Save(); Console.WriteLine($"获取access_token成结束:{Instance.access_token},旧:{access_token}"); } else { Console.WriteLine($"获取access_token失败:{r.body}"); } return(r); }
public async Task <HttpResult <file> > search(string pfid, string name) { var client = new Hclient <file>(); if (drive_id == null) { drive_id = token.Instance.default_drive_id; } if (parent_file_id == null) { parent_file_id = "root"; } query = $"parent_file_id='{pfid}' and name = '{name}'"; var r = await client.PostAsJsonAsync(DriveApi.file_search, new { limit, marker, drive_id, query, order_direction }); return(r); }