def upload(self, url=None, filepath=None, multipart=True, params=None, upload_processes=None, intelligent=False):
if params:  <EOL><INDENT>STORE_SCHEMA.check(params)<EOL><DEDENT>if filepath and url:  <EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if filepath:  <EOL><INDENT>if intelligent:<EOL><INDENT>response = intelligent_ingestion.upload(<EOL>self.apikey, filepath, self.storage, params=params, security=self.security<EOL>)<EOL><DEDENT>elif multipart:<EOL><INDENT>response = upload_utils.multipart_upload(<EOL>self.apikey, filepath, self.storage,<EOL>upload_processes=upload_processes, params=params, security=self.security<EOL>)<EOL>handle = response['<STR_LIT>']<EOL>return filestack.models.Filelink(handle, apikey=self.apikey, security=self.security)<EOL><DEDENT>else:  <EOL><INDENT>filename = os.path.basename(filepath)<EOL>mimetype = mimetypes.guess_type(filepath)[<NUM_LIT:0>]<EOL>files = {'<STR_LIT>': (filename, open(filepath, '<STR_LIT:rb>'), mimetype)}<EOL>if params:<EOL><INDENT>params['<STR_LIT:key>'] = self.apikey<EOL><DEDENT>else:<EOL><INDENT>params = {'<STR_LIT:key>': self.apikey}<EOL><DEDENT>path = '<STR_LIT>'.format(path=STORE_PATH, storage=self.storage)<EOL>if self.security:<EOL><INDENT>path = "<STR_LIT>".format(<EOL>path=path, policy=self.security['<STR_LIT>'].decode('<STR_LIT:utf-8>'),<EOL>signature=self.security['<STR_LIT>']<EOL>)<EOL><DEDENT>response = utils.make_call(<EOL>API_URL, '<STR_LIT>', path=path, params=params, files=files<EOL>)<EOL><DEDENT><DEDENT>else:  <EOL><INDENT>tasks = []<EOL>request_url_list = []<EOL>if utils.store_params_checker(params):<EOL><INDENT>store_task = utils.store_params_maker(params)<EOL>tasks.append(store_task)<EOL><DEDENT>if self.security:<EOL><INDENT>tasks.append(<EOL>'<STR_LIT>'.format(<EOL>policy=self.security['<STR_LIT>'].decode('<STR_LIT:utf-8>'),<EOL>signature=self.security['<STR_LIT>']<EOL>)<EOL>)<EOL><DEDENT>tasks = '<STR_LIT:/>'.join(tasks)<EOL>if tasks:<EOL><INDENT>request_url_list.extend((CDN_URL, self.apikey, tasks, url))<EOL><DEDENT>else:<EOL><INDENT>request_url_list.extend((CDN_URL, self.apikey, url))<EOL><DEDENT>request_url = '<STR_LIT:/>'.join(request_url_list)<EOL>response = requests.post(request_url, headers=HEADERS)<EOL><DEDENT>if response.ok:<EOL><INDENT>response = response.json()<EOL>handle = re.match(<EOL>r'<STR_LIT>',<EOL>response['<STR_LIT:url>']<EOL>).group(<NUM_LIT:1>)<EOL>return filestack.models.Filelink(handle, apikey=self.apikey, security=self.security)<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>
Uploads a file either through a local filepath or external_url.
Uses multipart by default and Intelligent Ingestion by default (if enabled).
You can specify the number of multipart processes and pass in parameters.

returns [Filestack.Filelink]
```python
from filestack import Client

client = Client("<API_KEY>")
filelink = client.upload(filepath='/path/to/file')

# to use different storage:
client = FilestackClient.new('API_KEY', storage='dropbox')
filelink = client.upload(filepath='/path/to/file', params={'container': 'my-container'})

# to use an external URL:
filelink = client.upload(external_url='https://www.example.com')

# to disable intelligent ingestion:
filelink = client.upload(filepath='/path/to/file', intelligent=False)
```