Monitoring file upload often gets stuck

Monitoring file upload often gets stuck

KarolisCAMax
Participant Participant
148 Views
0 Replies
Message 1 of 1

Monitoring file upload often gets stuck

KarolisCAMax
Participant
Participant

I am uploading files by using api methods, such as saveCopyAs, etc..

I want to open these files when they are uploaded, but very often the API gets stuck and I am not any outcome from the DataFileFuture object.

Is there any better way to do that? Or maybe there are some workarounds? It's very time consuming because each time I must reboot Fusion app..

source: adsk.fusion.Component = occ.component

# Save a copy of the component to a new file
future: adsk.core.DataFileFuture = source.saveCopyAs(
  source.partNumber, parent_folder, "", ""
)
monitor_upload(future, source.name)
new_doc = app.documents.open(future.dataFile)
adsk.doEvents()

def monitor_upload(future :adsk.core.DataFileFuture, part_code):
    uploading = True
    while uploading:
        if future.uploadState == adsk.core.UploadStates.UploadFinished:
            uploading = False
            app.log('Uploaded: ' + part_code)
        elif future.uploadState == adsk.core.UploadStates.UploadFailed:
            ui.messageBox('The upload failed.')
            uploading = False
        adsk.doEvents()
0 Likes
149 Views
0 Replies
Replies (0)