Author |
|
Jannix Newbie
Joined: 19 October 2020
Online Status: Offline Posts: 8
|
Posted: 23 November 2020 at 2:47am | IP Logged
|
|
|
Hi,
I'm trying to upload a file using webapi. I saw on the doc what parameters is needed (unfortunatly it's the only request without an example):
{
Type string Type of storage - personal, corporate.
Path string Path to folder than should contain uploaded file.
FileData string Uploaded file information. Contains fields size, name, tmp_name.
}
so my request paramters look like that :
'{"Type":"personal","Path":"/","FileData":"{ "size":"' + file.size + '", "name":"' + file.filename + '", "tmp_name":"tmpname"}"}'
However I receive a 103 errorcode. So what am I missing please?
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 23 November 2020 at 5:04am | IP Logged
|
|
|
We'll look into this, and most likely will provide a sample shortly. Thanks.
--
Regards,
Igor, Afterlogic Support
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 24 November 2020 at 3:01am | IP Logged
|
|
|
Developers confirmed that it'll only work if the file was uploaded via AJAX using form, file detals need to be supplied by web browser.
We've just added a sample for file upload to Using Web API documentation page.
Also, it seems that Web API docs are bit outdated, this will be looked into as well.
--
Regards,
Igor, Afterlogic Support
|
Back to Top |
|
|
Jannix Newbie
Joined: 19 October 2020
Online Status: Offline Posts: 8
|
Posted: 24 November 2020 at 7:10am | IP Logged
|
|
|
Thanks for your answer.
I think I already have the right form format uploaded to my server but then I don't know in which syntax to pass it down to the web api.
I look forward to read your sample.
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 24 November 2020 at 9:36am | IP Logged
|
|
|
Well the sample is already available here and we hope it helps.
--
Regards,
Igor, Afterlogic Support
|
Back to Top |
|
|
Jannix Newbie
Joined: 19 October 2020
Online Status: Offline Posts: 8
|
Posted: 25 November 2020 at 6:55am | IP Logged
|
|
|
Thanks, it helped but even after adding the jua-uploader for the file to be uploaded. I still receive a 103 errocode and so whatever is the type of the file I'm passing (right as I receive it through my server or after save it locally and then pass it to UploadFile).
I'll do more digging to see what I did wrong.
|
Back to Top |
|
|
Jannix Newbie
Joined: 19 October 2020
Online Status: Offline Posts: 8
|
Posted: 19 January 2021 at 2:37am | IP Logged
|
|
|
Hi again,
so I've been trying for a while to make it work but I'm lost.
I understand that it seems to work only from Ajax request but for cors issues I've been using the webApi from my server side.
The thing is I upload my file to my server and then use URLSearchParams to create the request to the WebAPI. For other requests it works fine but here it seems that the type of the file doesn't match what's expected.
I start to believe that it isn't possible to make my upload request from my server.
Do you have any inputs that could help or is it really not possible?
server side code if it can help:
@ApiOperation({ title: 'Upload file into Aurora' })
@Post('upload')
@ApiImplicitFile({ name: 'file', required: true })
@UseInterceptors(FileInterceptor('file'))
public async upload(@Response() res, @UploadedFile() file) {
this.fileMService.UPdoRequestToAurora('Files', 'UploadFile',
'{ "Type": "personal", "Path": "" }', file)
.then(data => data.json())
.then(json => {
console.log(json);
});
return res.status(HttpStatus.OK).json('{upload: true}');
}
///UPdoRequestToAurora function :
UPdoRequestToAurora(module: string, method: string, parameters = '', file): Promise<any> {
const requestBody = new URLSearchParams({'Module': module, 'Method': method,
'jua-uploader': file, 'Parameters': parameters, 'jua-post-type': 'ajax'});
return fetch(this.AURORA_API_LOCAL, {method: 'POST', body: requestBody,
headers: {Authorization: 'Bearer ' + this.AUTH_TOKEN}});
}
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 19 January 2021 at 3:09am | IP Logged
|
|
|
As stated previously, developers have explicitly confirmed that this is only going to work if the file was uploaded via AJAX using form, and the file detals must be supplied by web browser.
--
Regards,
Igor, Afterlogic Support
|
Back to Top |
|
|