|
// For complete examples and data files, please go to https://github.com/aspose-cad-cloud/aspose-cad-cloud-dotnet/ |
|
|
|
using Aspose.CAD.Cloud.Sdk.Api; |
|
using Aspose.CAD.Cloud.Sdk.Model.Requests; |
|
|
|
namespace Aspose.CAD_Cloud_APIs_Examples |
|
{ |
|
class CADExamples |
|
{ |
|
protected string AppKey = ""; // Get App Key and App SID from https://dashboard.aspose.cloud/ |
|
protected string AppSid = ""; // Get App Key and App SID from https://dashboard.aspose.cloud/ |
|
|
|
static void Main(string[] args) |
|
{ |
|
CADExamples cadExamples = new CADExamples(); |
|
|
|
// Get properties of an image |
|
cadExamples.GetImageProperties(); |
|
} |
|
|
|
// Get properties of an image |
|
private void GetImageProperties() |
|
{ |
|
CadApi cadApi = new CadApi(AppKey, AppSid); |
|
string fileName = "910609.dxf"; |
|
|
|
// Upload document to Cloud Storage |
|
uploadFileToCloudStorage(fileName); |
|
|
|
var request = new GetDrawingPropertiesRequest(fileName, null, null); |
|
var properties = cadApi.GetDrawingProperties(request); |
|
} |
|
|
|
private string pathToDataDir() |
|
{ |
|
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory; |
|
var folders = Path.GetDirectoryName(baseDirectory).Split('\\').ToList(); |
|
// Get Path to the TestData directory |
|
var foldersUpToRootDir = folders.Take(folders.Count - 5); |
|
var pathToRootDir = string.Join("\\", foldersUpToRootDir); |
|
return Path.Combine(pathToRootDir, "TestData"); |
|
} |
|
|
|
private void uploadFileToCloudStorage(String fileName) |
|
{ |
|
CadApi storageApi = new CadApi(AppKey, AppSid); |
|
|
|
string dataFilePath = Path.Combine(pathToDataDir(), fileName); |
|
|
|
UploadFileRequest putCreateRequest = new UploadFileRequest(fileName, File.OpenRead(dataFilePath)); |
|
storageApi.UploadFile(putCreateRequest); |
|
} |
|
|
|
private void saveFileToDisk(Stream responseStream, String destFileName) |
|
{ |
|
var fileStream = File.Create(Path.Combine(pathToDataDir(), "Output", destFileName)); |
|
responseStream.Seek(0, SeekOrigin.Begin); |
|
responseStream.CopyTo(fileStream); |
|
fileStream.Close(); |
|
} |
|
} |
|
} |