Skip to content

Commit 88168d1

Browse files
committed
update demo
1 parent c0bf470 commit 88168d1

File tree

5 files changed

+34
-31
lines changed

5 files changed

+34
-31
lines changed

SDK/Aspose.OMR.Cloud.SDK/Internal/RequestHandlers/JwtRequestHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal class JwtRequestHandler : IRequestHandler
1414
private readonly ApiInvoker apiInvoker;
1515

1616
private string accessToken;
17-
private string refreshToken;
17+
//private string refreshToken;
1818

1919
public JwtRequestHandler(Configuration configuration)
2020
{

SDK/Aspose.OMR.Cloud.SDK/Model/Requests/FolderRequests/CreateFolderRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public CreateFolderRequest()
4242
/// </summary>
4343
/// <param name="path">Folder path to create e.g. &#39;folder_1/folder_2/&#39;</param>
4444
/// <param name="storageName">Storage name</param>
45-
public CreateFolderRequest(string path, string storageName = null)
45+
public CreateFolderRequest(string path, string storageName)
4646
{
4747
this.path = path;
4848
this.storageName = storageName;

SDK/Aspose.OMR.Demo/Aspose.OMR.Demo.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
<WarningLevel>4</WarningLevel>
3232
</PropertyGroup>
3333
<ItemGroup>
34-
<Reference Include="Aspose.Storage.Cloud.Sdk, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
35-
<HintPath>..\packages\Aspose.Storage-Cloud.18.3.0\lib\net20\Aspose.Storage.Cloud.Sdk.dll</HintPath>
36-
</Reference>
3734
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
3835
<HintPath>..\packages\Newtonsoft.Json.11.0.1\lib\net20\Newtonsoft.Json.dll</HintPath>
3936
</Reference>

SDK/Aspose.OMR.Demo/Program.cs

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018 Aspose Pty Ltd. All Rights Reserved.
2+
* Copyright (c) 2020 Aspose Pty Ltd. All Rights Reserved.
33
*
44
* Licensed under the MIT (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,19 +14,15 @@
1414
* limitations under the License.
1515
*/
1616

17-
using Aspose.Omr.Cloud.Sdk;
18-
using Aspose.Omr.Cloud.Sdk.Model;
19-
using Aspose.Omr.Cloud.Sdk.Model.Requests;
20-
2117
namespace Aspose.OMR.Demo
2218
{
2319
using System;
2420
using System.Collections.Generic;
2521
using System.IO;
26-
using Storage.Cloud.Sdk;
27-
using Storage.Cloud.Sdk.Api;
28-
using Storage.Cloud.Sdk.Model;
29-
using Storage.Cloud.Sdk.Model.Requests;
22+
using Aspose.Omr.Cloud.Sdk;
23+
using Aspose.Omr.Cloud.Sdk.Api;
24+
using Aspose.Omr.Cloud.Sdk.Model;
25+
using Aspose.Omr.Cloud.Sdk.Model.Requests;
3026
using Newtonsoft.Json;
3127
using Newtonsoft.Json.Linq;
3228
using FileInfo = Aspose.Omr.Cloud.Sdk.Model.FileInfo;
@@ -125,6 +121,16 @@ class OmrDemo
125121
/// </summary>
126122
private StorageApi StorageApi = null;
127123

124+
/// <summary>
125+
/// Instance of Cloud Folder API
126+
/// </summary>
127+
private FolderApi FolderApi = null;
128+
129+
/// <summary>
130+
/// Instance of Cloud File API
131+
/// </summary>
132+
private FileApi FileApi = null;
133+
128134
/// <summary>
129135
/// Instance of OMR API
130136
/// </summary>
@@ -137,35 +143,36 @@ public OmrDemo()
137143
string configFileRelativePath = Path.Combine(this.demoDataSubmoduleName, this.configFileName);
138144

139145
// Locate submodule folder containing demo data and config
140-
//while (current != null && !File.Exists(Path.Combine(current.FullName, configFileRelativePath)))
141-
//{
142-
// current = current.Parent;
143-
//}
144-
145-
146+
while (current != null && !File.Exists(Path.Combine(current.FullName, configFileRelativePath)))
147+
{
148+
current = current.Parent;
149+
}
146150

147151
// Check if config file exists
148152
if (current == null)
149153
{
150154
throw new Exception($"Unable to find {this.configFileName}");
151155
}
152156

153-
// string configFilePath = Path.Combine(current.FullName, configFileRelativePath);
154-
string configFilePath = Path.Combine($"C:\\Users\\MAKS\\Desktop\\Новая папка\\aspose-omr-cloud-dotnet", configFileRelativePath);
157+
string configFilePath = Path.Combine(current.FullName, configFileRelativePath);
155158

156159
// parse config
157160
this.Config = JObject.Parse(File.ReadAllText(configFilePath));
158161
this.DataFolder = Path.Combine(Directory.GetParent(configFilePath).FullName, this.Config["data_folder"].ToString());
159162

160163
// create storage api and provide parameters
161164
string baseHost = new Uri(this.Basepath).GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped).ToString();
165+
162166
Configuration storageConfiguration = new Configuration();
163167
storageConfiguration.AppKey = this.AppKey;
164168
storageConfiguration.AppSid = this.AppSid;
165169
storageConfiguration.ApiBaseUrl = baseHost;
170+
166171
this.StorageApi = new StorageApi(storageConfiguration);
172+
this.FolderApi = new FolderApi(storageConfiguration);
173+
this.FileApi = new FileApi(storageConfiguration);
167174

168-
this.OmrApi = new OmrApi(this.AppKey, this.AppSid);
175+
this.OmrApi = new OmrApi(storageConfiguration);
169176
}
170177

171178
/// <summary>
@@ -330,8 +337,8 @@ protected void UploadFile(string srcFile, string dstPath)
330337
{
331338
using (FileStream fs = new FileStream(srcFile, FileMode.Open))
332339
{
333-
UploadResponse response = this.StorageApi.PutCreate(new PutCreateRequest(dstPath, fs));
334-
Console.WriteLine($"File {dstPath} uploaded successfully with response {response.Status}");
340+
FilesUploadResult response = FileApi.UploadFile(new UploadFileRequest(dstPath, fs));
341+
Console.WriteLine($"File {dstPath} uploaded successfully with response {response}");
335342
}
336343
}
337344

@@ -342,18 +349,18 @@ protected void UploadFile(string srcFile, string dstPath)
342349
protected void UploadDemoFiles(string dataDirPath)
343350
{
344351
// check if folder already exists on storage
345-
FileExistResponse response = this.StorageApi.GetIsExist(new GetIsExistRequest(this.LogosFolderName));
346-
if (response.FileExist.IsExist == false)
352+
ObjectExist response = this.StorageApi.ObjectExists(new ObjectExistsRequest(this.LogosFolderName));
353+
if (response.Exists == false)
347354
{
348-
this.StorageApi.PutCreateFolder(new PutCreateFolderRequest(this.LogosFolderName));
355+
FolderApi.CreateFolder(new CreateFolderRequest(this.LogosFolderName, "storage"));
349356
}
350357

351358
// upload logo images
352359
foreach (string logo in this.templateLogosImagesNames)
353360
{
354361
string destLogoPath = $"{this.LogosFolderName}/{logo}";
355-
response = this.StorageApi.GetIsExist(new GetIsExistRequest(destLogoPath));
356-
if (response.FileExist.IsExist == false)
362+
response = this.StorageApi.ObjectExists(new ObjectExistsRequest(destLogoPath));
363+
if (response.Exists == false)
357364
{
358365
this.UploadFile(Path.Combine(dataDirPath, logo), destLogoPath);
359366
}

SDK/Aspose.OMR.Demo/packages.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Aspose.Storage-Cloud" version="18.3.0" targetFramework="net20" />
43
<package id="Newtonsoft.Json" version="11.0.1" targetFramework="net20" />
54
</packages>

0 commit comments

Comments
 (0)