1+ import { AxiosPromise } from 'axios' ;
12import fs from 'fs' ;
23import path from 'path' ;
3- import http from '../http' ;
4+ import { http } from '../http' ;
45import { FormData } from '../types/Http' ;
56import {
67 FetchStatResponse ,
@@ -12,11 +13,11 @@ import {
1213const FILE_MANAGER_V2_API_PATH = 'filemanager/api/v2' ;
1314const FILE_MANAGER_V3_API_PATH = 'filemanager/api/v3' ;
1415
15- export async function uploadFile (
16+ export function uploadFile (
1617 accountId : number ,
1718 src : string ,
1819 dest : string
19- ) : Promise < UploadResponse > {
20+ ) : AxiosPromise < UploadResponse > {
2021 const directory = path . dirname ( dest ) ;
2122 const filename = path . basename ( dest ) ;
2223 const formData : FormData = {
@@ -34,29 +35,29 @@ export async function uploadFile(
3435 formData . folderPath = '/' ;
3536 }
3637
37- return http . post ( accountId , {
38+ return http . post < UploadResponse > ( accountId , {
3839 url : `${ FILE_MANAGER_V3_API_PATH } /files/upload` ,
3940 data : formData ,
4041 headers : { 'Content-Type' : 'multipart/form-data' } ,
4142 } ) ;
4243}
4344
44- export async function fetchStat (
45+ export function fetchStat (
4546 accountId : number ,
4647 src : string
47- ) : Promise < FetchStatResponse > {
48- return http . get ( accountId , {
48+ ) : AxiosPromise < FetchStatResponse > {
49+ return http . get < FetchStatResponse > ( accountId , {
4950 url : `${ FILE_MANAGER_V2_API_PATH } /files/stat/${ src } ` ,
5051 } ) ;
5152}
5253
53- export async function fetchFiles (
54+ export function fetchFiles (
5455 accountId : number ,
5556 folderId : number | 'None' ,
5657 offset : number ,
5758 archived ?: boolean
58- ) : Promise < FetchFilesResponse > {
59- return http . get ( accountId , {
59+ ) : AxiosPromise < FetchFilesResponse > {
60+ return http . get < FetchFilesResponse > ( accountId , {
6061 url : `${ FILE_MANAGER_V2_API_PATH } /files/` ,
6162 params : {
6263 hidden : 0 ,
@@ -67,11 +68,11 @@ export async function fetchFiles(
6768 } ) ;
6869}
6970
70- export async function fetchFolders (
71+ export function fetchFolders (
7172 accountId : number ,
7273 folderId : number | 'None'
73- ) : Promise < FetchFolderResponse > {
74- return http . get ( accountId , {
74+ ) : AxiosPromise < FetchFolderResponse > {
75+ return http . get < FetchFolderResponse > ( accountId , {
7576 url : `${ FILE_MANAGER_V2_API_PATH } /folders/` ,
7677 params : {
7778 hidden : 0 ,
0 commit comments