@@ -128,7 +128,7 @@ export default class WolaiDocumentService implements DocumentService {
128128 Object . keys ( data . policyData . formData ) . forEach ( ( key ) => {
129129 formData . append ( key , data . policyData . formData [ key ] ) ;
130130 } ) ;
131- formData . append ( 'key' , filekey ) ;
131+ formData . append ( 'key' , data . fileUrl ) ;
132132 formData . append ( 'success_action_status' , '200' ) ;
133133 formData . append ( 'file' , file ) ;
134134 await this . requestWithCookie ( async ( header ) => {
@@ -148,7 +148,7 @@ export default class WolaiDocumentService implements DocumentService {
148148 spaceId : repository . spaceId ,
149149 type : 'string' ,
150150 bucket : data . policyData . bucket ,
151- filename : filekey ,
151+ filename : data . fileUrl ,
152152 pageTitle : title ,
153153 pageId : documentId ,
154154 } ,
@@ -244,13 +244,17 @@ export default class WolaiDocumentService implements DocumentService {
244244
245245 getFileUrl = async ( repository : WolaiRepository , file : File ) => {
246246 return this . requestWithCookie ( async ( header ) => {
247+ // FIXME: 这里简单获取了文件后缀名,考虑到网页上的文件类型都是比较简单的,不会有类似 xxx.tar.gz 这种长后缀
248+ // 构造一个合法的新文件名,避免上传接口报错
249+ const fileName = `${ this . getUuid ( ) } .${ file ?. name ?. split ( '.' ) . pop ( ) } `
247250 return this . request . post (
248251 await this . webRequestService . changeUrl ( 'v1/file/getSignedPostUrl' , header ) ,
249252 {
250253 data : {
251254 spaceId : repository . spaceId ,
252255 fileSize : file . size ,
253256 type : 'import' ,
257+ fileName,
254258 } ,
255259 }
256260 ) ;
0 commit comments