Skip to content

Commit 5ae0200

Browse files
authored
Merge pull request #253 from ankadada/master
增加$filePath传值
2 parents 79290fd + e5d8612 commit 5ae0200

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

src/Qiniu/Storage/FormUploader.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ public static function put(
3030
$data,
3131
$config,
3232
$params,
33-
$mime
33+
$mime,
34+
$checkCrc,
35+
$filePath
3436
) {
3537

3638
$fields = array('token' => $upToken);
3739
if ($key === null) {
38-
$fname = 'filename';
40+
$fname = $filePath;
3941
} else {
40-
$fname = $key;
42+
$fname = $filePath;
4143
$fields['key'] = $key;
4244
}
4345

src/Qiniu/Storage/ResumeUploader.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function __construct(
7171
/**
7272
* 上传操作
7373
*/
74-
public function upload()
74+
public function upload($filePath)
7575
{
7676
$uploaded = 0;
7777
while ($uploaded < $this->size) {
@@ -106,7 +106,7 @@ public function upload()
106106
array_push($this->contexts, $ret['ctx']);
107107
$uploaded += $blockSize;
108108
}
109-
return $this->makeFile();
109+
return $this->makeFile($filePath);
110110
}
111111

112112
/**
@@ -118,13 +118,14 @@ private function makeBlock($block, $blockSize)
118118
return $this->post($url, $block);
119119
}
120120

121-
private function fileUrl()
121+
private function fileUrl($filePath)
122122
{
123123
$url = $this->host . '/mkfile/' . $this->size;
124124
$url .= '/mimeType/' . \Qiniu\base64_urlSafeEncode($this->mime);
125125
if ($this->key != null) {
126126
$url .= '/key/' . \Qiniu\base64_urlSafeEncode($this->key);
127127
}
128+
$url .= '/fname/' . \Qiniu\base64_urlSafeEncode($filePath);
128129
if (!empty($this->params)) {
129130
foreach ($this->params as $key => $value) {
130131
$val = \Qiniu\base64_urlSafeEncode($value);
@@ -137,9 +138,9 @@ private function fileUrl()
137138
/**
138139
* 创建文件
139140
*/
140-
private function makeFile()
141+
private function makeFile($filePath)
141142
{
142-
$url = $this->fileUrl();
143+
$url = $this->fileUrl($filePath);
143144
$body = implode(',', $this->contexts);
144145
$response = $this->post($url, $body);
145146
if ($response->needRetry()) {

src/Qiniu/Storage/UploadManager.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public function put(
5656
$this->config,
5757
$params,
5858
$mime,
59-
$checkCrc
59+
$checkCrc,
60+
$filePath
6061
);
6162
}
6263

@@ -106,7 +107,8 @@ public function putFile(
106107
$this->config,
107108
$params,
108109
$mime,
109-
$checkCrc
110+
$checkCrc,
111+
$filePath
110112
);
111113
}
112114

@@ -119,7 +121,7 @@ public function putFile(
119121
$mime,
120122
$this->config
121123
);
122-
$ret = $up->upload();
124+
$ret = $up->upload($filePath);
123125
fclose($file);
124126
return $ret;
125127
}

0 commit comments

Comments
 (0)