File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Src/Notion.Client/RestClient Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -93,15 +93,20 @@ public async Task DeleteAsync(
9393 }
9494
9595 public async Task < UploadResponse > Upload ( string filePath , JsonSerializerSettings serializerSettings = null )
96+ {
97+ var fileStream = File . OpenRead ( filePath ) ;
98+ return await Upload ( fileStream , Path . GetFileName ( filePath ) , serializerSettings ) ;
99+ }
100+
101+ public async Task < UploadResponse > Upload ( Stream stream , string filename , JsonSerializerSettings serializerSettings = null )
96102 {
97103 var response = await this . PostAsync < UploadResponse > ( "https://api.notion.com/v1/file_uploads" ,
98104 new UploadRequest { Mode = "single_part" } ) ;
99105
100106 using ( var formData = new MultipartFormDataContent ( ) )
101107 {
102- var fileStream = File . OpenRead ( filePath ) ;
103- var fileContent = new StreamContent ( fileStream ) ;
104- formData . Add ( fileContent , "file" , Path . GetFileName ( filePath ) ) ;
108+ var fileContent = new StreamContent ( stream ) ;
109+ formData . Add ( fileContent , "file" , filename ) ;
105110
106111 var uploadResponse = await this . SendAsync ( response . UploadUrl , HttpMethod . Post , attachContent : message =>
107112 {
You can’t perform that action at this time.
0 commit comments