Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
.DS_Store
*.swp
.DS_Store
*.swp
*.suo

bin
obj
123 changes: 110 additions & 13 deletions Example/RSDemo.cs → Demo/Demo.cs
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,38 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using QBox.Auth;
using QBox.RS;
using QBox.FileOp;

namespace QBox.Example
namespace QBox.Demo
{
public class RSDemo
public class Demo
{
public static string bucketName;
public static string key;
public static string localFile;
public static string DEMO_DOMAIN;
public static Client conn;
public static RSService rs;
public static ImageOp imageOp;

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

bucketName = "csharpbucket";
DEMO_DOMAIN = "iovip.qbox.me/csharpbucket";
DEMO_DOMAIN = "csharpbucket.dn.qbox.me";
localFile = "Resource/gogopher.jpg";
key = "gogopher.jpg";

conn = new DigestAuthClient();
rs = new RSService(conn, bucketName);
localFile = Process.GetCurrentProcess().MainModule.FileName;
key = System.IO.Path.GetFileName(localFile);

CallRet callRet = rs.MkBucket();
PrintRet(callRet);
imageOp = new ImageOp(conn);

RSPutFile();
MkBucket();
RSClientPutFile();
Get();
Stat();
Expand All @@ -41,9 +38,21 @@ public static void Main()
Delete();
Drop();

MkBucket();
RSPutFile();
Publish();
ImageOps();

Console.ReadLine();
}

public static void MkBucket()
{
Console.WriteLine("\n===> RSService.MkBucket");
CallRet callRet = rs.MkBucket();
PrintRet(callRet);
}

public static void RSPutFile()
{
Console.WriteLine("\n===> RSService.PutFile");
Expand Down Expand Up @@ -199,6 +208,94 @@ public static void UnPublish()
}
}

public static void ImageOps()
{
Console.WriteLine("\n===> ImageInfo");
ImageInfoRet infoRet = imageOp.ImageInfo("http://" + DEMO_DOMAIN + "/" + key);
PrintRet(infoRet);
if (infoRet.OK)
{
Console.WriteLine("Format: " + infoRet.Format);
Console.WriteLine("Width: " + infoRet.Width);
Console.WriteLine("Heigth: " + infoRet.Height);
Console.WriteLine("ColorModel: " + infoRet.ColorModel);
}
else
{
Console.WriteLine("Failed to ImageInfo");
}

Console.WriteLine("\n===> ImageExif");
CallRet exifRet = imageOp.ImageExif("http://" + DEMO_DOMAIN + "/" + key);
PrintRet(exifRet);
if (!exifRet.OK)
{
Console.WriteLine("Failed to ImageExif");
}

Console.WriteLine("\n===> ImageViewUrl");
ImageViewSpec viewSpec = new ImageViewSpec{Mode = 0, Width = 200, Height= 200};
string viewUrl = imageOp.ImageViewUrl("http://" + DEMO_DOMAIN + "/" + key, viewSpec);
Console.WriteLine("ImageViewUrl 1:" + viewUrl);
viewSpec.Quality = 1;
viewSpec.Format = "gif";
viewUrl = imageOp.ImageViewUrl("http://" + DEMO_DOMAIN + "/" + key, viewSpec);
Console.WriteLine("ImageViewUrl 2:" + viewUrl);
viewSpec.Quality = 90;
viewSpec.Sharpen = 10;
viewSpec.Format = "png";
viewUrl = imageOp.ImageViewUrl("http://" + DEMO_DOMAIN + "/" + key, viewSpec);
Console.WriteLine("ImageViewUrl 3:" + viewUrl);

Console.WriteLine("\n===> ImageMogrifyUrl");
ImageMogrifySpec mogrSpec = new ImageMogrifySpec {
Thumbnail = "!50x50r", Gravity = "center", Rotate = 90,
Crop = "!50x50", Quality = 80, AutoOrient = true
};
string mogrUrl = imageOp.ImageMogrifyUrl("http://" + DEMO_DOMAIN + "/" + key, mogrSpec);
Console.WriteLine("ImageMogrifyUrl:" + mogrUrl);

Console.WriteLine("\n===> Get");
GetRet getRet = rs.Get(key, "save-as");
PrintRet(getRet);
if (getRet.OK)
{
Console.WriteLine("Hash: " + getRet.Hash);
Console.WriteLine("FileSize: " + getRet.FileSize);
Console.WriteLine("MimeType: " + getRet.MimeType);
Console.WriteLine("Url: " + getRet.Url);
}
else
{
Console.WriteLine("Failed to Get");
}
Console.WriteLine("\n===> ImageMogrifySaveAs");
PutFileRet saveAsRet = rs.ImageMogrifySaveAs(getRet.Url, mogrSpec, key + ".mogr-save-as");
PrintRet(saveAsRet);
if (saveAsRet.OK)
{
Console.WriteLine("Hash: " + saveAsRet.Hash);
}
else
{
Console.WriteLine("Failed to ImageMogrifySaveAs");
}
Console.WriteLine("\n===> Get");
getRet = rs.Get(key + ".mogr-save-as", "mogr-save-as.jpg");
PrintRet(getRet);
if (getRet.OK)
{
Console.WriteLine("Hash: " + getRet.Hash);
Console.WriteLine("FileSize: " + getRet.FileSize);
Console.WriteLine("MimeType: " + getRet.MimeType);
Console.WriteLine("Url: " + getRet.Url);
}
else
{
Console.WriteLine("Failed to Get");
}
}

public static void PrintRet(CallRet callRet)
{
Console.WriteLine("\n[CallRet]");
Expand Down
61 changes: 61 additions & 0 deletions Demo/Demo.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8BA368D7-3784-4C50-9A28-4FA1A9C81555}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Demo</RootNamespace>
<AssemblyName>Demo</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Content Include="Resource\gogopher.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Compile Include="Demo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\QBox\QBox.csproj">
<Project>{1C8C9909-57ED-44E4-81A5-0904E96FA00E}</Project>
<Name>QBox</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Binary file added Demo/Resource/gogopher.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified QBox/Auth/AuthPolicy.cs
100755 → 100644
Empty file.
Empty file modified QBox/Auth/DigestAuthClient.cs
100755 → 100644
Empty file.
Loading