Skip to content

Commit 5d6d7f4

Browse files
committed
Merge pull request #7 from shijiayun/master
增加 Visual C# 的工程文件,方便用户使用;去掉 PutAuth 的文档,修改了 DOMAIN。
2 parents 02974ec + bf72bcb commit 5d6d7f4

36 files changed

+689
-246
lines changed

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
.DS_Store
2-
*.swp
1+
.DS_Store
2+
*.swp
3+
*.suo
4+
5+
bin
6+
obj

Example/RSDemo.cs renamed to Demo/Demo.cs

Lines changed: 110 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,35 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Diagnostics;
62
using QBox.Auth;
73
using QBox.RS;
4+
using QBox.FileOp;
85

9-
namespace QBox.Example
6+
namespace QBox.Demo
107
{
11-
public class RSDemo
8+
public class Demo
129
{
1310
public static string bucketName;
1411
public static string key;
1512
public static string localFile;
1613
public static string DEMO_DOMAIN;
1714
public static Client conn;
1815
public static RSService rs;
16+
public static ImageOp imageOp;
1917

2018
public static void Main()
2119
{
2220
Config.ACCESS_KEY = "<Please apply your access key>";
2321
Config.SECRET_KEY = "<Dont send your secret key to anyone>";
2422

2523
bucketName = "csharpbucket";
26-
DEMO_DOMAIN = "iovip.qbox.me/csharpbucket";
24+
DEMO_DOMAIN = "csharpbucket.dn.qbox.me";
25+
localFile = "Resource/gogopher.jpg";
26+
key = "gogopher.jpg";
27+
2728
conn = new DigestAuthClient();
2829
rs = new RSService(conn, bucketName);
29-
localFile = Process.GetCurrentProcess().MainModule.FileName;
30-
key = System.IO.Path.GetFileName(localFile);
31-
32-
CallRet callRet = rs.MkBucket();
33-
PrintRet(callRet);
30+
imageOp = new ImageOp(conn);
3431

35-
RSPutFile();
32+
MkBucket();
3633
RSClientPutFile();
3734
Get();
3835
Stat();
@@ -41,9 +38,21 @@ public static void Main()
4138
Delete();
4239
Drop();
4340

41+
MkBucket();
42+
RSPutFile();
43+
Publish();
44+
ImageOps();
45+
4446
Console.ReadLine();
4547
}
4648

49+
public static void MkBucket()
50+
{
51+
Console.WriteLine("\n===> RSService.MkBucket");
52+
CallRet callRet = rs.MkBucket();
53+
PrintRet(callRet);
54+
}
55+
4756
public static void RSPutFile()
4857
{
4958
Console.WriteLine("\n===> RSService.PutFile");
@@ -199,6 +208,94 @@ public static void UnPublish()
199208
}
200209
}
201210

211+
public static void ImageOps()
212+
{
213+
Console.WriteLine("\n===> ImageInfo");
214+
ImageInfoRet infoRet = imageOp.ImageInfo("http://" + DEMO_DOMAIN + "/" + key);
215+
PrintRet(infoRet);
216+
if (infoRet.OK)
217+
{
218+
Console.WriteLine("Format: " + infoRet.Format);
219+
Console.WriteLine("Width: " + infoRet.Width);
220+
Console.WriteLine("Heigth: " + infoRet.Height);
221+
Console.WriteLine("ColorModel: " + infoRet.ColorModel);
222+
}
223+
else
224+
{
225+
Console.WriteLine("Failed to ImageInfo");
226+
}
227+
228+
Console.WriteLine("\n===> ImageExif");
229+
CallRet exifRet = imageOp.ImageExif("http://" + DEMO_DOMAIN + "/" + key);
230+
PrintRet(exifRet);
231+
if (!exifRet.OK)
232+
{
233+
Console.WriteLine("Failed to ImageExif");
234+
}
235+
236+
Console.WriteLine("\n===> ImageViewUrl");
237+
ImageViewSpec viewSpec = new ImageViewSpec{Mode = 0, Width = 200, Height= 200};
238+
string viewUrl = imageOp.ImageViewUrl("http://" + DEMO_DOMAIN + "/" + key, viewSpec);
239+
Console.WriteLine("ImageViewUrl 1:" + viewUrl);
240+
viewSpec.Quality = 1;
241+
viewSpec.Format = "gif";
242+
viewUrl = imageOp.ImageViewUrl("http://" + DEMO_DOMAIN + "/" + key, viewSpec);
243+
Console.WriteLine("ImageViewUrl 2:" + viewUrl);
244+
viewSpec.Quality = 90;
245+
viewSpec.Sharpen = 10;
246+
viewSpec.Format = "png";
247+
viewUrl = imageOp.ImageViewUrl("http://" + DEMO_DOMAIN + "/" + key, viewSpec);
248+
Console.WriteLine("ImageViewUrl 3:" + viewUrl);
249+
250+
Console.WriteLine("\n===> ImageMogrifyUrl");
251+
ImageMogrifySpec mogrSpec = new ImageMogrifySpec {
252+
Thumbnail = "!50x50r", Gravity = "center", Rotate = 90,
253+
Crop = "!50x50", Quality = 80, AutoOrient = true
254+
};
255+
string mogrUrl = imageOp.ImageMogrifyUrl("http://" + DEMO_DOMAIN + "/" + key, mogrSpec);
256+
Console.WriteLine("ImageMogrifyUrl:" + mogrUrl);
257+
258+
Console.WriteLine("\n===> Get");
259+
GetRet getRet = rs.Get(key, "save-as");
260+
PrintRet(getRet);
261+
if (getRet.OK)
262+
{
263+
Console.WriteLine("Hash: " + getRet.Hash);
264+
Console.WriteLine("FileSize: " + getRet.FileSize);
265+
Console.WriteLine("MimeType: " + getRet.MimeType);
266+
Console.WriteLine("Url: " + getRet.Url);
267+
}
268+
else
269+
{
270+
Console.WriteLine("Failed to Get");
271+
}
272+
Console.WriteLine("\n===> ImageMogrifySaveAs");
273+
PutFileRet saveAsRet = rs.ImageMogrifySaveAs(getRet.Url, mogrSpec, key + ".mogr-save-as");
274+
PrintRet(saveAsRet);
275+
if (saveAsRet.OK)
276+
{
277+
Console.WriteLine("Hash: " + saveAsRet.Hash);
278+
}
279+
else
280+
{
281+
Console.WriteLine("Failed to ImageMogrifySaveAs");
282+
}
283+
Console.WriteLine("\n===> Get");
284+
getRet = rs.Get(key + ".mogr-save-as", "mogr-save-as.jpg");
285+
PrintRet(getRet);
286+
if (getRet.OK)
287+
{
288+
Console.WriteLine("Hash: " + getRet.Hash);
289+
Console.WriteLine("FileSize: " + getRet.FileSize);
290+
Console.WriteLine("MimeType: " + getRet.MimeType);
291+
Console.WriteLine("Url: " + getRet.Url);
292+
}
293+
else
294+
{
295+
Console.WriteLine("Failed to Get");
296+
}
297+
}
298+
202299
public static void PrintRet(CallRet callRet)
203300
{
204301
Console.WriteLine("\n[CallRet]");

Demo/Demo.csproj

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{8BA368D7-3784-4C50-9A28-4FA1A9C81555}</ProjectGuid>
9+
<OutputType>Exe</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>Demo</RootNamespace>
12+
<AssemblyName>Demo</AssemblyName>
13+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14+
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
15+
<FileAlignment>512</FileAlignment>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
18+
<PlatformTarget>x86</PlatformTarget>
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
28+
<PlatformTarget>x86</PlatformTarget>
29+
<DebugType>pdbonly</DebugType>
30+
<Optimize>true</Optimize>
31+
<OutputPath>bin\Release\</OutputPath>
32+
<DefineConstants>TRACE</DefineConstants>
33+
<ErrorReport>prompt</ErrorReport>
34+
<WarningLevel>4</WarningLevel>
35+
</PropertyGroup>
36+
<ItemGroup>
37+
<Content Include="Resource\gogopher.jpg">
38+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
39+
</Content>
40+
</ItemGroup>
41+
<ItemGroup>
42+
<Compile Include="Demo.cs" />
43+
</ItemGroup>
44+
<ItemGroup>
45+
<ProjectReference Include="..\QBox\QBox.csproj">
46+
<Project>{1C8C9909-57ED-44E4-81A5-0904E96FA00E}</Project>
47+
<Name>QBox</Name>
48+
</ProjectReference>
49+
</ItemGroup>
50+
<ItemGroup>
51+
<Reference Include="System" />
52+
</ItemGroup>
53+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
54+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
55+
Other similar extension points exist, see Microsoft.Common.targets.
56+
<Target Name="BeforeBuild">
57+
</Target>
58+
<Target Name="AfterBuild">
59+
</Target>
60+
-->
61+
</Project>

Demo/Resource/gogopher.jpg

209 KB
Loading

QBox/Auth/AuthPolicy.cs

100755100644
File mode changed.

QBox/Auth/DigestAuthClient.cs

100755100644
File mode changed.

0 commit comments

Comments
 (0)