@@ -1806,12 +1806,12 @@ def upload_project_file(
18061806 project_name : str ,
18071807 filepath : str ,
18081808 * ,
1809- content_type : Optional [ str ] = None ,
1810- filename : Optional [ str ] = None ,
1811- file_id : Optional [ str ] = None ,
1812- activity_id : Optional [ str ] = None ,
1813- chunk_size : Optional [ int ] = None ,
1814- progress : Optional [ TransferProgress ] = None ,
1809+ content_type : str | None = None ,
1810+ filename : str | None = None ,
1811+ file_id : str | None = None ,
1812+ activity_id : str | None = None ,
1813+ chunk_size : int | None = None ,
1814+ progress : TransferProgress | None = None ,
18151815 ) -> requests .Response :
18161816 """Upload project file from a filepath.
18171817
@@ -1822,14 +1822,14 @@ def upload_project_file(
18221822 Args:
18231823 project_name (str): Project name.
18241824 filepath (str): Path where file will be downloaded.
1825- content_type (Optional[ str] ): MIME type of file.
1826- filename (Optional[ str] ): Server filename, filename from filepath
1825+ content_type (str | None ): MIME type of file.
1826+ filename (str | None ): Server filename, filename from filepath
18271827 is used if not passed.
1828- file_id (Optional[ str] ): File id.
1829- activity_id (Optional[ str] ): To which activity is file related.
1830- chunk_size (Optional[ int] ): Size of chunks that are received
1828+ file_id (str | None ): File id.
1829+ activity_id (str | None ): To which activity is file related.
1830+ chunk_size (int | None ): Size of chunks that are received
18311831 in single loop.
1832- progress (Optional[ TransferProgress] ): Object that gives ability
1832+ progress (TransferProgress | None ): Object that gives ability
18331833 to track download progress.
18341834
18351835 Returns:
@@ -1844,17 +1844,21 @@ def upload_project_file(
18441844 if not content_type :
18451845 content_type = "application/octet-stream"
18461846
1847- query = prepare_query_string ({
1848- "x_file_id" : file_id ,
1849- "x_activity_id" : activity_id ,
1850- })
1847+ headers = {}
1848+ if file_id :
1849+ headers ["x-file-id" ] = file_id
1850+
1851+ if activity_id :
1852+ headers ["x-activity-id" ] = activity_id
1853+
18511854 return self .upload_file (
1852- f"api/projects/{ project_name } /files{ query } " ,
1855+ f"api/projects/{ project_name } /files" ,
18531856 filepath ,
18541857 content_type = content_type ,
18551858 filename = filename ,
18561859 chunk_size = chunk_size ,
18571860 progress = progress ,
1861+ headers = headers ,
18581862 request_type = RequestTypes .post ,
18591863 )
18601864
@@ -1864,11 +1868,11 @@ def upload_project_file_from_stream(
18641868 stream : StreamType ,
18651869 filename : str ,
18661870 * ,
1867- content_type : Optional [ str ] = None ,
1868- file_id : Optional [ str ] = None ,
1869- activity_id : Optional [ str ] = None ,
1870- chunk_size : Optional [ int ] = None ,
1871- progress : Optional [ TransferProgress ] = None ,
1871+ content_type : str | None = None ,
1872+ file_id : str | None = None ,
1873+ activity_id : str | None = None ,
1874+ chunk_size : int | None = None ,
1875+ progress : TransferProgress | None = None ,
18721876 ) -> requests .Response :
18731877 """Upload project file from a filepath.
18741878
@@ -1880,12 +1884,12 @@ def upload_project_file_from_stream(
18801884 project_name (str): Project name.
18811885 stream (StreamType): Stream used as source for upload.
18821886 filename (str): Name of file on server.
1883- content_type (Optional[ str] ): MIME type of file.
1884- file_id (Optional[ str] ): File id.
1885- activity_id (Optional[ str] ): To which activity is file related.
1886- chunk_size (Optional[ int] ): Size of chunks that are received
1887+ content_type (str | None ): MIME type of file.
1888+ file_id (str | None ): File id.
1889+ activity_id (str | None ): To which activity is file related.
1890+ chunk_size (int | None ): Size of chunks that are received
18871891 in single loop.
1888- progress (Optional[ TransferProgress] ): Object that gives ability
1892+ progress (TransferProgress | None ): Object that gives ability
18891893 to track download progress.
18901894
18911895 Returns:
@@ -1898,17 +1902,21 @@ def upload_project_file_from_stream(
18981902 if not content_type :
18991903 content_type = "application/octet-stream"
19001904
1901- query = prepare_query_string ({
1902- "x_file_id" : file_id ,
1903- "x_activity_id" : activity_id ,
1904- })
1905+ headers = {}
1906+ if file_id :
1907+ headers ["x-file-id" ] = file_id
1908+
1909+ if activity_id :
1910+ headers ["x-activity-id" ] = activity_id
1911+
19051912 return self .upload_file_from_stream (
1906- f"api/projects/{ project_name } /files{ query } " ,
1913+ f"api/projects/{ project_name } /files" ,
19071914 stream ,
19081915 content_type = content_type ,
19091916 filename = filename ,
19101917 chunk_size = chunk_size ,
19111918 progress = progress ,
1919+ headers = headers ,
19121920 request_type = RequestTypes .post ,
19131921 )
19141922
0 commit comments