def upload_file(self, item, chunk_size=DEFAULT_UPLOAD_CHUNK_SIZE):
if item is None:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>item = Path(item) if not isinstance(item, Path) else item<EOL>if not item.exists():<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if not item.is_file():<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>file_size = item.stat().st_size<EOL>if file_size <= UPLOAD_SIZE_LIMIT_SIMPLE:<EOL><INDENT>url = self.build_url(<EOL>self._endpoints.get('<STR_LIT>').format(id=self.object_id,<EOL>filename=item.name))<EOL>headers = {'<STR_LIT>': '<STR_LIT>'}<EOL>with item.open(mode='<STR_LIT:rb>') as file:<EOL><INDENT>data = file.read()<EOL><DEDENT>response = self.con.put(url, headers=headers, data=data)<EOL>if not response:<EOL><INDENT>return None<EOL><DEDENT>data = response.json()<EOL>return self._classifier(data)(parent=self,<EOL>**{self._cloud_data_key: data})<EOL><DEDENT>else:<EOL><INDENT>url = self.build_url(<EOL>self._endpoints.get('<STR_LIT>').format(<EOL>id=self.object_id, filename=item.name))<EOL>response = self.con.post(url)<EOL>if not response:<EOL><INDENT>return None<EOL><DEDENT>data = response.json()<EOL>upload_url = data.get(self._cc('<STR_LIT>'), None)<EOL>if upload_url is None:<EOL><INDENT>log.error('<STR_LIT>'<EOL>'<STR_LIT>'.format(item.name))<EOL>return None<EOL><DEDENT>current_bytes = <NUM_LIT:0><EOL>with item.open(mode='<STR_LIT:rb>') as file:<EOL><INDENT>while True:<EOL><INDENT>data = file.read(chunk_size)<EOL>if not data:<EOL><INDENT>break<EOL><DEDENT>transfer_bytes = len(data)<EOL>headers = {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': str(len(data)),<EOL>'<STR_LIT>': '<STR_LIT>'<EOL>'<STR_LIT>'.format(current_bytes,<EOL>current_bytes +<EOL>transfer_bytes - <NUM_LIT:1>,<EOL>file_size)<EOL>}<EOL>current_bytes += transfer_bytes<EOL>response = self.con.naive_request(upload_url, '<STR_LIT>',<EOL>data=data,<EOL>headers=headers)<EOL>if not response:<EOL><INDENT>return None<EOL><DEDENT>if response.status_code != <NUM_LIT>:<EOL><INDENT>data = response.json()<EOL>return self._classifier(data)(parent=self, **{<EOL>self._cloud_data_key: data})<EOL><DEDENT><DEDENT><DEDENT><DEDENT>
Uploads a file

        :param item: path to the item you want to upload
        :type item: str or Path
        :param chunk_size: Only applies if file is bigger than 4MB.
         Chunk size for uploads. Must be a multiple of 327.680 bytes
        :return: uploaded file
        :rtype: DriveItem