Skip to content

Commit d7f1791

Browse files
authored
Merge pull request #93 from liangchaoboy/addFname
addFname
2 parents 26464e6 + ad6bcb7 commit d7f1791

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

Qiniu/IO/Resumable/ResumablePut.cs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Text;
5-
#if NET40
6-
using System.Threading.Tasks;
7-
#endif
8-
using Qiniu.Auth;
9-
using Qiniu.Conf;
10-
using Qiniu.RPC;
11-
using Qiniu.RS;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Text;
5+
#if NET40
6+
using System.Threading.Tasks;
7+
#endif
8+
using Qiniu.Auth;
9+
using Qiniu.Conf;
10+
using Qiniu.RPC;
11+
using Qiniu.RS;
1212
using Qiniu.Util;
1313

1414
namespace Qiniu.IO.Resumable
@@ -77,14 +77,16 @@ public CallRet PutFile(string upToken, string localFile, string key)
7777
throw new Exception(string.Format("{0} does not exist", localFile));
7878
}
7979

80+
string fname = Path.GetFileName(localFile);
81+
8082
PutAuthClient client = new PutAuthClient(upToken);
8183
CallRet ret;
8284
using (FileStream fs = File.OpenRead(localFile))
8385
{
8486
int block_cnt = block_count(fs.Length);
8587
long fsize = fs.Length;
8688
extra.Progresses = new BlkputRet[block_cnt];
87-
byte[] byteBuf = new byte[BLOCKSIZE];
89+
byte[] byteBuf = new byte[BLOCKSIZE];
8890
int readLen = BLOCKSIZE;
8991
for (int i = 0; i < block_cnt; i++)
9092
{
@@ -103,7 +105,7 @@ public CallRet PutFile(string upToken, string localFile, string key)
103105
extra.OnNotify(new PutNotifyEvent(i, readLen, extra.Progresses[i]));
104106
}
105107
}
106-
ret = Mkfile(client, key, fsize);
108+
ret = Mkfile(client, key, fsize,fname);
107109
}
108110
if (ret.OK)
109111
{
@@ -172,14 +174,18 @@ private BlkputRet Mkblock(Client client, byte[] firstChunk, int blkSize)
172174
return null;
173175
}
174176

175-
private CallRet Mkfile(Client client, string key, long fsize)
177+
private CallRet Mkfile(Client client, string key, long fsize, string fname)
176178
{
177179
StringBuilder urlBuilder = new StringBuilder();
178180
urlBuilder.AppendFormat("{0}/mkfile/{1}", Config.UP_HOST, fsize);
179181
if (key != null)
180182
{
181183
urlBuilder.AppendFormat("/key/{0}", Base64URLSafe.ToBase64URLSafe(key));
182184
}
185+
if (fname != null)
186+
{
187+
urlBuilder.AppendFormat("/fname/{0}", Base64URLSafe.ToBase64URLSafe(fname));
188+
}
183189
if (!string.IsNullOrEmpty(extra.MimeType))
184190
{
185191
urlBuilder.AppendFormat("/mimeType/{0}", Base64URLSafe.ToBase64URLSafe(extra.MimeType));
@@ -220,4 +226,4 @@ private int block_count(long fsize)
220226
return (int)((fsize + blockMashk) >> blockBits);
221227
}
222228
}
223-
}
229+
}

0 commit comments

Comments
 (0)