Skip to content

Commit

Permalink
another try
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Jun 23, 2023
1 parent 15be526 commit f94e81c
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,26 @@ Cypress.Commands.add('uploadFile', (fileName, mimeType, target) => {
}
cy.request('/csrftoken')
.then(({ body }) => {
const requesttoken = body.token
return axios.put(`${url}/remote.php/webdav/${fileName}`, file, {
cy.wait(1000)
return cy.wrap(body.token)
})
.then(async (requesttoken) => {
const response = await axios.put(`${url}/remote.php/webdav/${fileName}`, file, {
headers: {
requesttoken,
'Content-Type': mimeType,
},
}).then(response => {
const fileId = Number(
response.headers['oc-fileid']?.split('oc')?.[0]
)
cy.log(`Uploaded ${fileName}`,
response.status,
{ fileId }
)
return fileId
})
return cy.wrap(response)
}).then(response => {
const fileId = Number(
response.headers['oc-fileid']?.split('oc')?.[0]
)
cy.log(`Uploaded ${fileName}`,
response.status,
{ fileId }
)
return cy.wrap(fileId)
})
})
})
Expand Down

0 comments on commit f94e81c

Please sign in to comment.