@@ 73-78 (lines=6) @@ | ||
70 | public static function upload($bucketName, $srcPath, $dstPath, |
|
71 | $bizAttr = null, $sliceSize = null, $insertOnly = null) |
|
72 | { |
|
73 | if (!file_exists($srcPath)) { |
|
74 | return [ |
|
75 | 'code' => self::COSAPI_PARAMS_ERROR, |
|
76 | 'message' => 'file '.$srcPath.' not exists', |
|
77 | 'data' => [], ]; |
|
78 | } |
|
79 | ||
80 | $dstPath = '/'.ltrim($dstPath, '/'); |
|
81 | ||
@@ 334-339 (lines=6) @@ | ||
331 | $srcPath = realpath($srcPath); |
|
332 | $dstPath = self::cosUrlEncode($dstPath); |
|
333 | ||
334 | if (filesize($srcPath) >= self::MAX_UNSLICE_FILE_SIZE) { |
|
335 | return [ |
|
336 | 'code' => self::COSAPI_PARAMS_ERROR, |
|
337 | 'message' => 'file '.$srcPath.' larger then 20M, please use upload_slice interface', |
|
338 | 'data' => [], ]; |
|
339 | } |
|
340 | ||
341 | $expired = self::time() + self::EXPIRED_SECONDS; |
|
342 | $url = self::generateResUrl($bucketName, $dstPath); |
|
@@ 516-522 (lines=7) @@ | ||
513 | $srcPath, false, null, |
|
514 | $offset, $sliceSize); |
|
515 | ||
516 | if ($filecontent === false) { |
|
517 | return [ |
|
518 | 'code' => self::COSAPI_PARAMS_ERROR, |
|
519 | 'message' => 'read file '.$srcPath.' error', |
|
520 | 'data' => [], |
|
521 | ]; |
|
522 | } |
|
523 | ||
524 | $boundary = '---------------------------'.substr(md5(mt_rand()), 0, 10); |
|
525 | $data = self::generateSliceBody( |