0

how to copy a file that has been uploaded

Is there provision in the api for copy a file that has been uploaded and renaming it?

3 comments

  • 0
    Avatar
    KP

    At the moment, we don't have a way to copy or rename files in the API. We're working on some changes to the way files are handled though, and this is something we'll hope to include. Currently if you want to remove and re-upload a file attached to a Note for example, you could do something like this:

        # get the Note
        result = sg.find('Note', [ ['id','is',211]], ['title','attachments'])
        # remove ALL attachments on the Note (these will still be in Shotgun as File(s) but will no longer be linked to the Note)
        result = sg.update('Note', 211, {'attachments':[]})
        # upload a new file to my Note
        result = sg.upload_file('Note', 211, '/path/to/photo/of/my/doggy.jpg')
    
    
  • 0
    Avatar
    Dennis Christopher

    Thanks for the reply, Kevin.

    I've uploaded files to specific shots, but can't seem to find any way to query them. I dont see the linkage between the Shot and the file.

    Also I've tried  e.g. result = sg.find('File',[])

    What is the way to do this?

  • 0
    Avatar
    KP

    You've caught us with our pants down... :) We currently don't allow direct access to files (Attachments) via the API. This is mainly because it's a bit confusing how they work at the moment and we'll be making some significant changes shortly which will end up causing users grief having to re-write scripts to adjust for the changes. So in short, right now there's no way to do it, but look for this to change in v2.1 coming in early July.

Please sign in to leave a comment.