Skip to content

Commit 5fa3c6c

Browse files
GroupDocs.Viewer Cloud Examples Updated with V2
1 parent fb8d5d2 commit 5fa3c6c

49 files changed

Lines changed: 1287 additions & 2 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>GroupDocs.Viewer.Cloud.Python.Examples</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.python.pydev.PyDevBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.python.pydev.pythonNature</nature>
16+
</natures>
17+
</projectDescription>

.pydevproject

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<?eclipse-pydev version="1.0"?><pydev_project>
3+
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
4+
<path>/${PROJECT_DIR_NAME}/src</path>
5+
<path>/${PROJECT_DIR_NAME}</path>
6+
</pydev_pathproperty>
7+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
8+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
9+
</pydev_project>

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,25 @@
1-
# groupdocs-viewer-cloud-python-samples-
2-
GroupDocs.Viewer Cloud SDK for Python examples, plugins and showcase projects
1+
## GroupDocs.Viewer Cloud SDK for Python
2+
3+
[GroupDocs.Viewer Cloud SDK for Python](https://products.groupdocs.cloud/viewer/python) has been developed to help you get started with using our document viewer REST API, allowing to seamlessly convert your documents to any format you need. With this single API, you can convert back and forth between over 50 types of documents and images, including all Microsoft Office and OpenDocument file formats, PDF documents, HTML, CAD, raster images and many more.
4+
5+
This repository contains [Examples](Examples) projects for [GroupDocs.Viewer Cloud SDK for Python](https://products.groupdocs.cloud/viewer/python) to help you learn and write your own applications.
6+
7+
<p align="center">
8+
9+
<a title="Download complete GroupDocs.Viewer Cloud SDK Examples for Python source code" href="https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-php-samples/archive/master.zip">
10+
<img src="https://raw.github.com/AsposeExamples/java-examples-dashboard/master/images/downloadZip-Button-Large.png" />
11+
</a>
12+
</p>
13+
14+
Directory | Description
15+
--------- | -----------
16+
[Examples](Examples) | A collection of Python Cloud SDK examples that help you learn the product features
17+
18+
## Resources
19+
20+
+ **Website:** [www.GroupDocs.cloud](http://www.GroupDocs.cloud)
21+
+ **Product Home:** [GroupDocs.Viewer Cloud SDK for Python](https://products.groupdocs.cloud/viewer/python)
22+
+ **Download:** [Download GroupDocs.Viewer Cloud SDK for Python](https://pypi.org/project/groupdocs-viewer-cloud/)
23+
+ **Documentation:** [GroupDocs.Viewer Cloud SDK Documentation](https://docs.groupdocs.cloud/display/viewercloud/Home)
24+
+ **Free Support:** [GroupDocs.Viewer Cloud SDK Free Support Forum](https://forum.groupdocs.cloud/c/viewer)
25+
+ **Blog:** [GroupDocs.Viewer Cloud SDK Blog](https://blog.groupdocs.cloud/category/viewer/)

src/Common_Utilities/Utils.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import groupdocs_viewer_cloud
2+
import os
3+
4+
class Common_Utilities:
5+
6+
# Get your app_sid and app_key at https://dashboard.groupdocs.cloud (free registration is required).
7+
app_sid = None
8+
app_key = None
9+
host_url = None
10+
myStorage = None
11+
12+
@classmethod
13+
def Get_ViewerApi_Instance(self):
14+
# Create instance of the API
15+
return groupdocs_viewer_cloud.ViewerApi.from_keys(Common_Utilities.app_sid, Common_Utilities.app_key)
16+
17+
@classmethod
18+
def Get_StorageApi_Instance(self):
19+
# Create instance of the API
20+
return groupdocs_viewer_cloud.StorageApi.from_keys(Common_Utilities.app_sid, Common_Utilities.app_key)
21+
22+
@classmethod
23+
def Get_FolderApi_Instance(self):
24+
# Create instance of the API
25+
return groupdocs_viewer_cloud.FolderApi.from_keys(Common_Utilities.app_sid, Common_Utilities.app_key)
26+
27+
@classmethod
28+
def Get_FileApi_Instance(self):
29+
# Create instance of the API
30+
return groupdocs_viewer_cloud.FileApi.from_keys(Common_Utilities.app_sid, Common_Utilities.app_key)
31+
32+
@classmethod
33+
def Upload_Test_Files(self):
34+
35+
dirName = "D:\\ewspace\\GroupDocs.Viewer.Cloud.Python.Examples\\src\\Resources\\viewerdocs\\"
36+
37+
TestFiles = Common_Utilities.getListOfFiles(dirName)
38+
39+
# api initialization
40+
storageApi = Common_Utilities.Get_StorageApi_Instance()
41+
fileApi = Common_Utilities.Get_FileApi_Instance()
42+
43+
print("Files Count: " + str(len(TestFiles)))
44+
45+
for item in TestFiles:
46+
print("File to Upload: "+ dirName + item)
47+
# skip existing file uploading
48+
fileExistRequest = groupdocs_viewer_cloud.ObjectExistsRequest(dirName + item)
49+
fileExistsResponse = storageApi.object_exists(fileExistRequest)
50+
if not fileExistsResponse.exists:
51+
# file content uploading
52+
putCreateRequest = groupdocs_viewer_cloud.UploadFileRequest('viewerdocs\\' + item, dirName + item)
53+
fileApi.upload_file(putCreateRequest)
54+
print("Uploaded missing file: "+ 'viewerdocs\\' + item)
55+
56+
print("File Uploading completed..")
57+
58+
@classmethod
59+
def getListOfFiles(self, dirName):
60+
# create a list of file and sub directories
61+
# names in the given directory
62+
listOfFile = os.listdir(dirName)
63+
allFiles = list()
64+
# Iterate over all the entries
65+
for entry in listOfFile:
66+
# Create full path
67+
fullPath = os.path.join("", entry)
68+
# If entry is a directory then get the list of files in this directory
69+
if os.path.isdir(fullPath):
70+
allFiles = allFiles + Common_Utilities.getListOfFiles(fullPath)
71+
else:
72+
allFiles.append(fullPath)
73+
74+
return allFiles
8.45 KB
Binary file not shown.
13.9 KB
Binary file not shown.
10 KB
Binary file not shown.
283 KB
Binary file not shown.
15.1 KB
Binary file not shown.
447 KB
Binary file not shown.

0 commit comments

Comments
 (0)