Last active
February 4, 2019 06:00
-
-
Save aspose-cloud/f4514c834e8a9e661e8a8beab0b0dc39 to your computer and use it in GitHub Desktop.
The GIST contains SDK Examples of Aspose.Diagram REST APIs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The GIST contains SDK Examples of Aspose.Diagram REST APIs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-node | |
const { DiagramFileApi, DiagramFile_PutCreateRequest } = require("asposediagramcloud"); | |
var AppSid = "" // Get App Key and App SID from https://dashboard.aspose.cloud/ | |
var AppKey = "" // Get App Key and App SID from https://dashboard.aspose.cloud/ | |
diagramFileApi = new DiagramFileApi(AppSid, AppKey); | |
var req = new DiagramFile_PutCreateRequest(); | |
req.name = "file_create_node.vdx"; | |
req.isOverwrite = true; | |
diagramFileApi.diagramFilePutCreate(req).then((result) => { | |
console.log('API Response:', result); | |
}).catch(function(err) { | |
// Deal with an error | |
console.log('Error:', err); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-java/ | |
import com.aspose.cloud.diagram.api.DiagramFileApi; | |
import com.aspose.cloud.diagram.api.OAuthApi; | |
import com.aspose.cloud.diagram.client.ApiClient; | |
import com.aspose.cloud.diagram.client.ApiException; | |
import com.aspose.cloud.diagram.model.AccessTokenResponse; | |
import com.aspose.cloud.diagram.model.FileFormatRequest; | |
import com.aspose.cloud.diagram.model.SaaSposeResponse; | |
import com.aspose.cloud.diagram.model.SaveResponse; | |
import java.io.File; | |
/** | |
* Created by sohail on 02/02/2019. | |
*/ | |
public class DiagramSDKExamples { | |
private static String accesstoken; | |
private static String grantType = "client_credentials"; | |
private static String clientId = ""; // Get App key and App SID from https://dashboard.aspose.cloud/ | |
private static String clientSecret = ""; // Get App key and App SID from https://dashboard.aspose.cloud/ | |
private static String basePath = "https://api.aspose.cloud/v1.1"; | |
public static void main(String[] args) { | |
DiagramSDKExamples diagramSDKExamples = new DiagramSDKExamples(); | |
// Create new file | |
diagramSDKExamples.createNewFile(); | |
} | |
public void createNewFile() { | |
try { | |
DiagramFileApi diagramAPI = new DiagramFileApi(); | |
diagramAPI.setApiClient(getAPIClient()); | |
String name = "file_create_java.vdx"; | |
String folder = null; | |
Boolean isOverwrite = true; | |
String storage = null; | |
SaaSposeResponse response = diagramAPI.diagramFilePutCreate(name, folder, isOverwrite, storage); | |
System.out.println("API Response: " + response); | |
} catch (Exception e) { | |
System.out.println(e.getMessage()); | |
} | |
} | |
public static ApiClient getAPIClient() { | |
DiagramFileApi apiTask = new DiagramFileApi(); | |
ApiClient apiClient = new ApiClient(); | |
apiClient.setBasePath(basePath); | |
apiClient.addDefaultHeader("Authorization", "Bearer " + getAccessToken()); | |
apiTask.setApiClient(apiClient); | |
return apiClient; | |
} | |
public static String getAccessToken() { | |
try { | |
if (accesstoken == null || accesstoken == "") { | |
ApiClient apiClient = new ApiClient(); | |
apiClient.setBasePath("https://api.aspose.cloud/"); | |
OAuthApi oauth2 = new OAuthApi(); | |
oauth2.setApiClient(apiClient); | |
AccessTokenResponse accessTokenResponse = oauth2.oAuthPost(grantType, clientId, clientSecret); | |
accesstoken = accessTokenResponse.getAccessToken(); | |
} | |
} catch (ApiException e) { | |
System.out.println(e.getMessage()); | |
} | |
return accesstoken; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-php | |
<?php | |
require_once(__DIR__ . '/vendor/autoload.php'); | |
require_once(__DIR__ . '/Utils.php'); | |
use Aspose\Diagram\Cloud\Api\DiagramFileApi; | |
use \Aspose\Diagram\Cloud\Configuration; | |
use \Aspose\Diagram\Cloud\Model; | |
use \Aspose\Diagram\Cloud\ObjectSerializer; | |
class DiagramFile { | |
public $diagramApi; | |
public function __construct() { | |
$this->diagramApi = new DiagramFileApi(); | |
$config = $this->diagramApi->getConfig(); | |
$token = Utils::getAccessToken(); | |
$config ->setAccessToken($token); | |
} | |
public function createNewFile() { | |
$fileName = "file_create_php.vdx"; | |
$isOverwrite = 'true'; | |
$folder= ""; | |
$result = $this->diagramApi->diagramFilePutCreate($fileName, $folder, $isOverwrite); | |
$json = json_decode($result); | |
print_r ( $json ); | |
} | |
} | |
$diagramFile = new DiagramFile(); | |
$diagramFile->createNewFile(); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-python/ | |
import os | |
import asposediagramcloud | |
from asposediagramcloud.apis.diagram_file_api import DiagramFileApi | |
from asposediagramcloud.models import FileFormatRequest | |
import examples_base | |
api_client = examples_base.GetApiClient() | |
diagramAPI = asposediagramcloud.apis.diagram_file_api.DiagramFileApi(api_client) | |
filename ='file_create_python.vdx' | |
folder = "" | |
is_overwrite = "true" | |
result = diagramAPI.diagram_file_put_create(filename, folder=folder, is_overwrite=is_overwrite) | |
print(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-node | |
const { DiagramFileApi, DiagramFile_GetDiagramRequest } = require("asposediagramcloud"); | |
var AppSid = "" // Get App Key and App SID from https://dashboard.aspose.cloud/ | |
var AppKey = "" // Get App Key and App SID from https://dashboard.aspose.cloud/ | |
diagramFileApi = new DiagramFileApi(AppSid, AppKey); | |
var StorageApi = require("asposestoragecloud") | |
var config = {'appSid':AppSid, 'apiKey':AppKey}; | |
var storageApi = new StorageApi(config); | |
var fileName = 'file_get_1.vdx'; | |
var data_path = '../testData/'; | |
storageApi.PutCreate(fileName, versionId=null, storage=null, file=data_path + fileName , function(responseMessage) { | |
console.log('status:', responseMessage.status); | |
console.log('body:', responseMessage.body); | |
}); | |
var req = new DiagramFile_GetDiagramRequest(); | |
req.format = "pdf"; | |
req.name = fileName; | |
diagramFileApi.diagramFileGetDiagram(req).then((result) => { | |
console.log('API Response:', result); | |
}).catch(function(err) { | |
// Deal with an error | |
console.log('Error:', err); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-java/ | |
import com.aspose.cloud.diagram.api.DiagramFileApi; | |
import com.aspose.cloud.diagram.api.OAuthApi; | |
import com.aspose.cloud.diagram.client.ApiClient; | |
import com.aspose.cloud.diagram.client.ApiException; | |
import com.aspose.cloud.diagram.model.AccessTokenResponse; | |
import com.aspose.cloud.diagram.model.FileFormatRequest; | |
import com.aspose.cloud.diagram.model.SaaSposeResponse; | |
import com.aspose.cloud.diagram.model.SaveResponse; | |
import java.io.File; | |
/** | |
* Created by sohail on 02/02/2019. | |
*/ | |
public class DiagramSDKExamples { | |
private static String accesstoken; | |
private static String grantType = "client_credentials"; | |
private static String clientId = ""; // Get App key and App SID from https://dashboard.aspose.cloud/ | |
private static String clientSecret = ""; // Get App key and App SID from https://dashboard.aspose.cloud/ | |
private static String basePath = "https://api.aspose.cloud/v1.1"; | |
public static void main(String[] args) { | |
DiagramSDKExamples diagramSDKExamples = new DiagramSDKExamples(); | |
// Get document info | |
diagramSDKExamples.getDocumentInfo(); | |
} | |
public void getDocumentInfo() { | |
try { | |
DiagramFileApi api = new DiagramFileApi(); | |
String name = "file_get_1.vdx"; | |
String format = "pdf"; | |
String folder = null; | |
String storage = null; | |
// Upload file to Cloud Storage | |
uploadFile(name, "src/main/resources/" + name); | |
api.setApiClient(getAPIClient()); | |
File response = api.diagramFileGetDiagram(name, format, folder, storage); | |
System.out.println(response.getAbsolutePath()); | |
} catch (Exception e) { | |
System.out.println(e.getMessage()); | |
} | |
} | |
public void uploadFile(String name, String localFilePath) { | |
try { | |
DiagramFileApi diagramAPI = new DiagramFileApi(); | |
diagramAPI.setApiClient(getAPIClient()); | |
String folder = null; | |
Boolean isOverwrite = true; | |
String storage = null; | |
// Upload file to Cloud Storage | |
SaaSposeResponse response = diagramAPI.diagramFilePutUpload(localFilePath, name, folder, isOverwrite, storage); | |
System.out.println("API Response: " + response); | |
} catch (Exception e) { | |
System.out.println(e.getMessage()); | |
} | |
} | |
public static ApiClient getAPIClient() { | |
DiagramFileApi apiTask = new DiagramFileApi(); | |
ApiClient apiClient = new ApiClient(); | |
apiClient.setBasePath(basePath); | |
apiClient.addDefaultHeader("Authorization", "Bearer " + getAccessToken()); | |
apiTask.setApiClient(apiClient); | |
return apiClient; | |
} | |
public static String getAccessToken() { | |
try { | |
if (accesstoken == null || accesstoken == "") { | |
ApiClient apiClient = new ApiClient(); | |
apiClient.setBasePath("https://api.aspose.cloud/"); | |
OAuthApi oauth2 = new OAuthApi(); | |
oauth2.setApiClient(apiClient); | |
AccessTokenResponse accessTokenResponse = oauth2.oAuthPost(grantType, clientId, clientSecret); | |
accesstoken = accessTokenResponse.getAccessToken(); | |
} | |
} catch (ApiException e) { | |
System.out.println(e.getMessage()); | |
} | |
return accesstoken; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-php | |
<?php | |
require_once(__DIR__ . '/vendor/autoload.php'); | |
require_once(__DIR__ . '/Utils.php'); | |
use Aspose\Diagram\Cloud\Api\DiagramFileApi; | |
use \Aspose\Diagram\Cloud\Configuration; | |
use \Aspose\Diagram\Cloud\Model; | |
use \Aspose\Diagram\Cloud\ObjectSerializer; | |
class DiagramFile { | |
public $diagramApi; | |
public function __construct() { | |
$this->diagramApi = new DiagramFileApi(); | |
$config = $this->diagramApi->getConfig(); | |
$token = Utils::getAccessToken(); | |
$config ->setAccessToken($token); | |
} | |
public function getDocumentInfo() { | |
$fileName ='file_get_1.vdx'; | |
// Upload file to Cloud Storage | |
$localFilePath = realpath(__DIR__ . '/..') . '/testData/' . $fileName; | |
$folder = ""; | |
Utils::upload($localFilePath, $fileName, $folder); | |
$folder = ""; | |
$result = $this->diagramApi->diagramFileGetDiagram($fileName, "pdf", $folder, null); | |
print_r ( $result ); | |
} | |
} | |
$diagramFile = new DiagramFile(); | |
$diagramFile->getDocumentInfo(); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-python/ | |
import os | |
import asposediagramcloud | |
from asposediagramcloud.apis.diagram_file_api import DiagramFileApi | |
from asposediagramcloud.models import FileFormatRequest | |
import examples_base | |
api_client = examples_base.GetApiClient() | |
diagramAPI = asposediagramcloud.apis.diagram_file_api.DiagramFileApi(api_client) | |
ABSPATH = os.path.abspath(os.path.realpath(os.path.dirname(__file__)) + "/..") | |
dataFolder = os.path.join(ABSPATH, "testData") | |
filename ='file_get_1.vdx' | |
folder = '' | |
# Upload file to Cloud Storage | |
filePath = os.path.join(dataFolder, filename) | |
examples_base.Upload(filePath, filename, folder=None, storage=None) | |
result = diagramAPI.diagram_file_get_diagram(filename, format="pdf", folder=folder) | |
print(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-node | |
const { DiagramFileApi, DiagramFile_PostSaveAsRequest, FileFormatRequest } = require("asposediagramcloud"); | |
var AppSid = "" // Get App Key and App SID from https://dashboard.aspose.cloud/ | |
var AppKey = "" // Get App Key and App SID from https://dashboard.aspose.cloud/ | |
diagramFileApi = new DiagramFileApi(AppSid, AppKey); | |
var StorageApi = require("asposestoragecloud") | |
var config = {'appSid':AppSid, 'apiKey':AppKey}; | |
var storageApi = new StorageApi(config); | |
var fileName = '123.vsd'; | |
var data_path = '../testData/'; | |
storageApi.PutCreate(fileName, versionId=null, storage=null, file= data_path + fileName , function(responseMessage) { | |
console.log('status:', responseMessage.status); | |
console.log('body:', responseMessage.body); | |
}); | |
var req = new DiagramFile_PostSaveAsRequest(); | |
var format = new FileFormatRequest(); | |
format.format = "pdf"; | |
req.name = fileName; | |
req.isOverwrite = true; | |
req.newfilename = "file_saveas_1.pdf"; | |
req.format = format; | |
diagramFileApi.diagramFilePostSaveAs(req).then((result) => { | |
console.log('API Response:', result); | |
}).catch(function(err) { | |
// Deal with an error | |
console.log('Error:', err); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-java/ | |
import com.aspose.cloud.diagram.api.DiagramFileApi; | |
import com.aspose.cloud.diagram.api.OAuthApi; | |
import com.aspose.cloud.diagram.client.ApiClient; | |
import com.aspose.cloud.diagram.client.ApiException; | |
import com.aspose.cloud.diagram.model.AccessTokenResponse; | |
import com.aspose.cloud.diagram.model.FileFormatRequest; | |
import com.aspose.cloud.diagram.model.SaaSposeResponse; | |
import com.aspose.cloud.diagram.model.SaveResponse; | |
import java.io.File; | |
/** | |
* Created by sohail on 02/02/2019. | |
*/ | |
public class DiagramSDKExamples { | |
private static String accesstoken; | |
private static String grantType = "client_credentials"; | |
private static String clientId = ""; // Get App key and App SID from https://dashboard.aspose.cloud/ | |
private static String clientSecret = ""; // Get App key and App SID from https://dashboard.aspose.cloud/ | |
private static String basePath = "https://api.aspose.cloud/v1.1"; | |
public static void main(String[] args) { | |
DiagramSDKExamples diagramSDKExamples = new DiagramSDKExamples(); | |
// Save File as another format like 'png', 'pdf' and more | |
diagramSDKExamples.saveFileAsAnotherFormat(); | |
} | |
public void saveFileAsAnotherFormat() { | |
try { | |
DiagramFileApi diagramAPI = new DiagramFileApi(); | |
diagramAPI.setApiClient(getAPIClient()); | |
String name = "file_get_1.vdx"; | |
FileFormatRequest format = new FileFormatRequest(); | |
format.setFormat("pdf"); | |
String newfilename = "file_saveas_java.pdf"; | |
String folder = null; | |
Boolean isOverwrite = true; | |
String storage = null; | |
// Upload file to Cloud Storage | |
uploadFile(name, "src/main/resources/" + name); | |
SaveResponse response = diagramAPI.diagramFilePostSaveAs(name, format, newfilename, folder, isOverwrite, storage); | |
System.out.println("API Response: " + response); | |
} catch (Exception e) { | |
System.out.println(e.getMessage()); | |
} | |
} | |
public void uploadFile(String name, String localFilePath) { | |
try { | |
DiagramFileApi diagramAPI = new DiagramFileApi(); | |
diagramAPI.setApiClient(getAPIClient()); | |
String folder = null; | |
Boolean isOverwrite = true; | |
String storage = null; | |
// Upload file to Cloud Storage | |
SaaSposeResponse response = diagramAPI.diagramFilePutUpload(localFilePath, name, folder, isOverwrite, storage); | |
System.out.println("API Response: " + response); | |
} catch (Exception e) { | |
System.out.println(e.getMessage()); | |
} | |
} | |
public static ApiClient getAPIClient() { | |
DiagramFileApi apiTask = new DiagramFileApi(); | |
ApiClient apiClient = new ApiClient(); | |
apiClient.setBasePath(basePath); | |
apiClient.addDefaultHeader("Authorization", "Bearer " + getAccessToken()); | |
apiTask.setApiClient(apiClient); | |
return apiClient; | |
} | |
public static String getAccessToken() { | |
try { | |
if (accesstoken == null || accesstoken == "") { | |
ApiClient apiClient = new ApiClient(); | |
apiClient.setBasePath("https://api.aspose.cloud/"); | |
OAuthApi oauth2 = new OAuthApi(); | |
oauth2.setApiClient(apiClient); | |
AccessTokenResponse accessTokenResponse = oauth2.oAuthPost(grantType, clientId, clientSecret); | |
accesstoken = accessTokenResponse.getAccessToken(); | |
} | |
} catch (ApiException e) { | |
System.out.println(e.getMessage()); | |
} | |
return accesstoken; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-php | |
<?php | |
require_once(__DIR__ . '/vendor/autoload.php'); | |
require_once(__DIR__ . '/Utils.php'); | |
use Aspose\Diagram\Cloud\Api\DiagramFileApi; | |
use \Aspose\Diagram\Cloud\Configuration; | |
use \Aspose\Diagram\Cloud\Model; | |
use \Aspose\Diagram\Cloud\ObjectSerializer; | |
class DiagramFile { | |
public $diagramApi; | |
public function __construct() { | |
$this->diagramApi = new DiagramFileApi(); | |
$config = $this->diagramApi->getConfig(); | |
$token = Utils::getAccessToken(); | |
$config ->setAccessToken($token); | |
} | |
public function saveFileAsAnotherFormat() { | |
$fileName ='file_get_1.vdx'; | |
$isOverwrite = 'true'; | |
$folder= ""; | |
$format = new \Aspose\Diagram\Cloud\Model\FileFormatRequest(); | |
$format->setFormat("pdf"); | |
$newfilename = "file_saveas_php.pdf"; | |
$result = $this->diagramApi->DiagramFilePostSaveAs($fileName, $format, $newfilename, $folder, $isOverwrite); | |
$json = json_decode($result); | |
print_r ( $json ); | |
} | |
} | |
$diagramFile = new DiagramFile(); | |
$diagramFile->saveFileAsAnotherFormat(); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-python/ | |
import os | |
import asposediagramcloud | |
from asposediagramcloud.apis.diagram_file_api import DiagramFileApi | |
from asposediagramcloud.models import FileFormatRequest | |
import examples_base | |
api_client = examples_base.GetApiClient() | |
diagramAPI = asposediagramcloud.apis.diagram_file_api.DiagramFileApi(api_client) | |
ABSPATH = os.path.abspath(os.path.realpath(os.path.dirname(__file__)) + "/..") | |
dataFolder = os.path.join(ABSPATH, "testData") | |
filename ='file_get_1.vdx' | |
# Upload file to Cloud Storage | |
filePath = os.path.join(dataFolder, filename) | |
examples_base.Upload(filePath, filename, folder=None, storage=None) | |
# Convert file to PDF format | |
folder = "" | |
is_overwrite = "true" | |
format =FileFormatRequest(format="pdf") | |
newfilename = "file_saveas_python.pdf" | |
result = diagramAPI.diagram_file_post_save_as(filename, folder=folder, newfilename=newfilename, format=format, is_overwrite=is_overwrite) | |
print(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-node | |
var AppSid = "" // Get App Key and App SID from https://dashboard.aspose.cloud/ | |
var AppKey = "" // Get App Key and App SID from https://dashboard.aspose.cloud/ | |
var StorageApi = require("asposestoragecloud") | |
var config = {'appSid':AppSid, 'apiKey':AppKey}; | |
var storageApi = new StorageApi(config); | |
var fileName = 'file_get_1.vdx'; | |
var data_path = '../testData/'; | |
storageApi.PutCreate(fileName, versionId=null, storage=null, file= data_path + fileName , function(responseMessage) { | |
console.log('status:', responseMessage.status); | |
console.log('body:', responseMessage.body); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-java/ | |
import com.aspose.cloud.diagram.api.DiagramFileApi; | |
import com.aspose.cloud.diagram.api.OAuthApi; | |
import com.aspose.cloud.diagram.client.ApiClient; | |
import com.aspose.cloud.diagram.client.ApiException; | |
import com.aspose.cloud.diagram.model.AccessTokenResponse; | |
import com.aspose.cloud.diagram.model.FileFormatRequest; | |
import com.aspose.cloud.diagram.model.SaaSposeResponse; | |
import com.aspose.cloud.diagram.model.SaveResponse; | |
import java.io.File; | |
/** | |
* Created by sohail on 02/02/2019. | |
*/ | |
public class DiagramSDKExamples { | |
private static String accesstoken; | |
private static String grantType = "client_credentials"; | |
private static String clientId = ""; // Get App key and App SID from https://dashboard.aspose.cloud/ | |
private static String clientSecret = ""; // Get App key and App SID from https://dashboard.aspose.cloud/ | |
private static String basePath = "https://api.aspose.cloud/v1.1"; | |
public static void main(String[] args) { | |
DiagramSDKExamples diagramSDKExamples = new DiagramSDKExamples(); | |
// Upload file | |
diagramSDKExamples.uploadFile("file_get_1.vdx", "src/main/resources/file_get_1.vdx"); | |
} | |
public void uploadFile(String name, String localFilePath) { | |
try { | |
DiagramFileApi diagramAPI = new DiagramFileApi(); | |
diagramAPI.setApiClient(getAPIClient()); | |
String folder = null; | |
Boolean isOverwrite = true; | |
String storage = null; | |
// Upload file to Cloud Storage | |
SaaSposeResponse response = diagramAPI.diagramFilePutUpload(localFilePath, name, folder, isOverwrite, storage); | |
System.out.println("API Response: " + response); | |
} catch (Exception e) { | |
System.out.println(e.getMessage()); | |
} | |
} | |
public static ApiClient getAPIClient() { | |
DiagramFileApi apiTask = new DiagramFileApi(); | |
ApiClient apiClient = new ApiClient(); | |
apiClient.setBasePath(basePath); | |
apiClient.addDefaultHeader("Authorization", "Bearer " + getAccessToken()); | |
apiTask.setApiClient(apiClient); | |
return apiClient; | |
} | |
public static String getAccessToken() { | |
try { | |
if (accesstoken == null || accesstoken == "") { | |
ApiClient apiClient = new ApiClient(); | |
apiClient.setBasePath("https://api.aspose.cloud/"); | |
OAuthApi oauth2 = new OAuthApi(); | |
oauth2.setApiClient(apiClient); | |
AccessTokenResponse accessTokenResponse = oauth2.oAuthPost(grantType, clientId, clientSecret); | |
accesstoken = accessTokenResponse.getAccessToken(); | |
} | |
} catch (ApiException e) { | |
System.out.println(e.getMessage()); | |
} | |
return accesstoken; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-php | |
<?php | |
require_once(__DIR__ . '/vendor/autoload.php'); | |
require_once(__DIR__ . '/Utils.php'); | |
use Aspose\Diagram\Cloud\Api\DiagramFileApi; | |
use \Aspose\Diagram\Cloud\Configuration; | |
use \Aspose\Diagram\Cloud\Model; | |
use \Aspose\Diagram\Cloud\ObjectSerializer; | |
class DiagramFile { | |
public $diagramApi; | |
public function __construct() { | |
$this->diagramApi = new DiagramFileApi(); | |
$config = $this->diagramApi->getConfig(); | |
$token = Utils::getAccessToken(); | |
$config ->setAccessToken($token); | |
} | |
public function uploadFile() { | |
$fileName ='file_get_1.vdx'; | |
$isOverwrite = 'true'; | |
$folder= ""; | |
$localFilePath = realpath(__DIR__ . '/..') . '/testData/' . $fileName; | |
$result = $this->diagramApi->DiagramFilePutUpload($localFilePath, $fileName, $folder, $isOverwrite); | |
$json = json_decode($result); | |
print_r ( $json ); | |
} | |
} | |
$diagramFile = new DiagramFile(); | |
$diagramFile->uploadFile(); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-python/ | |
import os | |
import asposediagramcloud | |
from asposediagramcloud.apis.diagram_file_api import DiagramFileApi | |
from asposediagramcloud.models import FileFormatRequest | |
import examples_base | |
ABSPATH = os.path.abspath(os.path.realpath(os.path.dirname(__file__)) + "/..") | |
dataFolder = os.path.join(ABSPATH, "testData") | |
# Upload file to Cloud Storage | |
filename ='file_get_1.vdx' | |
filePath = os.path.join(dataFolder, filename) | |
result = examples_base.Upload(filePath, filename, folder=None, storage=None) | |
print(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment