Skip to content

Commit

Permalink
Merge pull request #1 from nakedmcse/waifuVault-fortran-new-password
Browse files Browse the repository at this point in the history
Change file upload password from parameter to body
  • Loading branch information
nakedmcse authored May 13, 2024
2 parents 08bd30e + 36dfbf7 commit 433916f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
31 changes: 28 additions & 3 deletions waifuAPIModule.f90
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ function uploadFile(fileObj) result (res)
! URL Upload
fields = 'url='
fields = trim(fields) // curl_easy_escape(curl_ptr, trim(fileObj%url), len_trim(fileObj%url))
if (len_trim(fileObj%password) > 0) then
fields = trim(fields) // '&password=' &
// curl_easy_escape(curl_ptr, trim(fileObj%password), len_trim(fileObj%password))
end if
call dispatch_curl(rc, 'PUT', trim(target_url), c_null_ptr, body, fields)
elseif (len_trim(fileObj%filename) > 0 .and. .not. allocated(fileObj%buffer)) then
! File Upload
Expand All @@ -95,7 +101,17 @@ function uploadFile(fileObj) result (res)
// 'Content-Length: ' // trim(stringsize) // achar(13) // achar(10) &
// 'Content-Type: octet-stream' // achar(13) // achar(10) // 'Content-Transfer-Encoding: binary' &
// achar(13) // achar(10) &
// achar(13) // achar(10) // filebuffer // achar(13) // achar(10) // '--' // seperator // '--'
// achar(13) // achar(10) // filebuffer // achar(13) // achar(10)
if (len_trim(fileObj%password) > 0) then
fields = fields // '--' // seperator // achar(13) // achar(10) &
// 'Content-Disposition: form-data; name="password"' // achar(13) // achar(10) &
// 'Content-Type: text/plain' // achar(13) // achar(10) &
// achar(13) // achar(10) // trim(fileObj%password) // achar(13) // achar(10)
endif
fields = fields // '--' // seperator // '--'
headers = c_null_ptr
headers = curl_slist_append(headers, ('Content-Type: multipart/form-data; boundary="' &
// seperator // '"'))
Expand All @@ -116,8 +132,17 @@ function uploadFile(fileObj) result (res)
// 'Content-Type: octet-stream' // achar(13) // achar(10) &
// 'Content-Transfer-Encoding: binary' &
// achar(13) // achar(10) &
// achar(13) // achar(10) // fileObj%buffer // achar(13) // achar(10) // '--' &
// seperator // '--'
// achar(13) // achar(10) // fileObj%buffer // achar(13) // achar(10)
if (len_trim(fileObj%password) > 0) then
fields = fields // '--' // seperator // achar(13) // achar(10) &
// 'Content-Disposition: form-data; name="password"' // achar(13) // achar(10) &
// 'Content-Type: text/plain' // achar(13) // achar(10) &
// achar(13) // achar(10) // trim(fileObj%password) // achar(13) // achar(10)
endif
fields = fields // '--' // seperator // '--'
headers = c_null_ptr
headers = curl_slist_append(headers, ('Content-Type: multipart/form-data; boundary="' &
// seperator // '"'))
Expand Down
3 changes: 0 additions & 3 deletions waifuModelsModule.f90
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ function build_url(this) result (res)
integer :: len
character(len=512) :: res
res = 'https://waifuvault.moe/rest?'
if(len_trim(this%password)>0) then
res = trim(res) // 'password=' // trim(this%password) // '&'
end if
if(len_trim(this%expires)>0) then
res = trim(res) // 'expires=' // trim(this%expires) // '&'
end if
Expand Down

0 comments on commit 433916f

Please sign in to comment.