MCPcopy Create free account
hub / github.com/CoderOpen/waimai / upload

Method upload

front/utils/luch-request/core/Request.js:265–367  ·  view source on GitHub ↗
(url, {
    // #ifdef APP-PLUS || H5
    files,
    // #endif
    // #ifdef MP-ALIPAY
    fileType,
    // #endif
    filePath,
    name,
    // #ifdef H5
    file,
    // #endif
    header = {},
    formData = {},
    custom = {},
    params = {},
    getTask
  })

Source from the content-addressed store, hash-verified

263 // #endif
264
265 upload(url, {
266 // #ifdef APP-PLUS || H5
267 files,
268 // #endif
269 // #ifdef MP-ALIPAY
270 fileType,
271 // #endif
272 filePath,
273 name,
274 // #ifdef H5
275 file,
276 // #endif
277 header = {},
278 formData = {},
279 custom = {},
280 params = {},
281 getTask
282 }) {
283 return new Promise((resolve, reject) => {
284 let next = true
285 const globalHeader = {...this.config.header}
286 delete globalHeader['content-type']
287 delete globalHeader['Content-Type']
288 const pubConfig = {
289 baseUrl: this.config.baseUrl,
290 url,
291 // #ifdef MP-ALIPAY
292 fileType,
293 // #endif
294 filePath,
295 method: 'UPLOAD',
296 name,
297 header: {...globalHeader, ...header},
298 formData,
299 params,
300 custom: {...this.config.custom, ...custom},
301 getTask: getTask || this.config.getTask
302 }
303 // #ifdef APP-PLUS || H5
304 if (files) {
305 pubConfig.files = files
306 }
307 // #endif
308 // #ifdef H5
309 if (file) {
310 pubConfig.file = file
311 }
312 // #endif
313 const cancel = (t = 'handle cancel', config = pubConfig) => {
314 const err = {
315 errMsg: t,
316 config: config
317 }
318 reject(err)
319 next = false
320 }
321
322 const handleRe = {...this.requestBeforeFun(pubConfig, cancel)}

Callers

nothing calls this directly

Calls 3

validateStatusMethod · 0.95
buildURLFunction · 0.85
buildFullPathFunction · 0.85

Tested by

no test coverage detected