Integrations/MicrosoftGraphFiles/MicrosoftGraphFiles.py
def upload_new_file(
        self, object_type, object_type_id, parent_id, file_name, entry_id
    ):
        """
        this function upload new file to a selected folder(parent_id)
        :param object_type: drive/ group/ me/ site/ users
        :param object_type_id: the selected object type id.
        :param parent_id: an ID of the folder to upload the file to.
        :param file_name: file name
        :param entry_id: demisto file entry ID
        :return: graph api raw response
        """
        file_path = demisto.getFilePath(entry_id).get("path")

        if "drives" == object_type:
            url = f"{object_type}/{object_type_id}/items/{parent_id}:/{file_name}:/content"

        elif object_type in ["groups", "users", "sites"]:
            url = f"{object_type}/{object_type_id}/drive/items/{parent_id}:/{file_name}:/content"
            # for sites, groups, users
        url = self.base_url + f"/{url}"
        with open(file_path, "rb") as file:
            self.headers["Content-Type"] = "application/octet-stream"
            return self.http_call(
                "PUT", full_url=url, headers=self.headers, url_suffix="", data=file
            )

        this function upload new file to a selected folder(parent_id)
        :param object_type: drive/ group/ me/ site/ users
        :param object_type_id: the selected object type id.
        :param parent_id: an ID of the folder to upload the file to.
        :param file_name: file name
        :param entry_id: demisto file entry ID
        :return: graph api raw response
        
this function upload new file to a selected folder(parent_id)
this function upload new file to a selected folder ( parent_id )
def upload_new_file(
        self, object_type, object_type_id, parent_id, file_name, entry_id
    ):
        file_path = demisto.getFilePath(entry_id).get("path")
        if "drives" == object_type:
            url = f"{object_type}/{object_type_id}/items/{parent_id}:/{file_name}:/content"
        elif object_type in ["groups", "users", "sites"]:
            url = f"{object_type}/{object_type_id}/drive/items/{parent_id}:/{file_name}:/content"
        url = self.base_url + f"/{url}"
        with open(file_path, "rb") as file:
            self.headers["Content-Type"] = "application/octet-stream"
            return self.http_call(
                "PUT", full_url=url, headers=self.headers, url_suffix="", data=file
            )
def upload_new_file ( self , object_type , object_type_id , parent_id , file_name , entry_id ) : file_path = demisto . getFilePath ( entry_id ) . get ( "path" ) if "drives" == object_type : url = f"{object_type}/{object_type_id}/items/{parent_id}:/{file_name}:/content" elif object_type in [ "groups" , "users" , "sites" ] : url = f"{object_type}/{object_type_id}/drive/items/{parent_id}:/{file_name}:/content" url = self . base_url + f"/{url}" with open ( file_path , "rb" ) as file : self . headers [ "Content-Type" ] = "application/octet-stream" return self . http_call ( "PUT" , full_url = url , headers = self . headers , url_suffix = "" , data = file )
this function upload new file to a selected folder(parent_id)
this function upload new file to a selected folder ( parent_id )
"""
        this function upload new file to a selected folder(parent_id)
        :param object_type: drive/ group/ me/ site/ users
        :param object_type_id: the selected object type id.
        :param parent_id: an ID of the folder to upload the file to.
        :param file_name: file name
        :param entry_id: demisto file entry ID
        :return: graph api raw response
        """ # for sites, groups, users
graph api raw response
graph api raw response
self
object_type
drive/ group/ me/ site/ users
drive / group / me / site / users
object_type_id
the selected object type id.
the selected object type id .
parent_id
an ID of the folder to upload the file to.
an ID of the folder to upload the file to .
file_name
None
entry_id
demisto file entry ID
demisto file entry ID