-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforge_sample.py
More file actions
50 lines (39 loc) · 1.54 KB
/
forge_sample.py
File metadata and controls
50 lines (39 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import streamlit as st
from dotenv import load_dotenv
load_dotenv()
import os
from autodesk_forge_sdk import OSSClient, OAuthTokenProvider
ossClient = OSSClient(OAuthTokenProvider(os.environ["FORGE_CLIENT_ID"], os.environ["FORGE_CLIENT_SECRET"]))
buckets = ossClient.get_all_buckets()
if 'bucket' not in st.session_state:
st.session_state['bucket'] = ''
if 'object' not in st.session_state:
st.session_state['object'] = ''
st.title("Autodesk Forge - Streamlite example")
col1, col2, col3 = st.columns(3)
with col1:
st.subheader("Buckets")
for bucket in buckets:
bucketKey = bucket["bucketKey"]
if st.button(bucketKey):
st.session_state['bucket'] = bucketKey
with col2:
st.subheader("Objects")
if st.session_state['bucket'] != '' :
objects = ossClient.get_all_objects(st.session_state['bucket'])
if not objects :
st.write('No objects in this bucket')
for object in objects :
objectKey = object["objectKey"]
if st.button(objectKey):
st.session_state['object'] = objectKey
with col3:
st.subheader('Details')
if st.session_state['bucket'] != '' and st.session_state['object'] != '':
bucketKey = st.session_state['bucket']
objectKey = st.session_state['object']
details = ossClient.get_object_details(bucketKey, objectKey)
st.write(f"Name: {details['objectKey']}")
st.write(f"Size: {details['size']}")
st.write(f"Location: {details['location']}")
st.write(f"SHA1: {details['sha1']}")