Hi guys, this is my first time writing here, and the reason is that I can’t find the solution to this problem.
I want to record an audio file and then upload it to ACRCLOUD service for recognition. The audio file is correctly created, but when I try to upload it (using Transfer Native Plugin) I always get FileTransferError 1:
Here is my code:
saveUpload(){
var path = null;
var file_name = "new2";
var file_extension = null;
if(this.plt.is('ios')){
file_extension = ".wav";
path = this.file.tempDirectory;
}else{
file_extension = ".aac";
path = this.file.externalRootDirectory;
}
this.file.createFile(path, file_name + file_extension, true).then((fileEntry) => {
var audio = this.media.create(fileEntry.toURL() );
audio.startRecord();
window.setTimeout(() => {
audio.stopRecord();
var formData = {
access_key: 'xxxxxxxxxxxxxxxxxx',
data_type: 'audio',
signature_version: 1,
signature: this.signature,
sample_bytes: 10000,
timestamp: this.timestamp
}
let options: FileUploadOptions = {
fileKey : "sample",
fileName : fileEntry.toURL().substr(fileEntry.toURL().lastIndexOf('/') + 1),
httpMethod : "POST",
params : formData,
headers : {},
mimeType : 'audio/acc'
};
var fileTransfer = this.transfer.create();
fileTransfer.upload(fileEntry.toURL(), encodeURI('http://identify-us-west-2.acrcloud.com/v1/identify'), options)
.then((data) => {
console.log(data);
}, (err) => {
console.log(err);
})
}, 10000);
});
}
}
The error is:
FileTransferError
body:"<!DOCTYPE html>↵<html>↵<head>↵<title>Error</title>↵<style>↵ body {↵ width: 35em;↵ margin: 0 auto;↵ font-family: Tahoma, Verdana, Arial, sans-serif;↵ }↵</style>↵</head>↵<body>↵<h1>An error occurred.</h1>↵<p>Sorry, the page you are looking for is currently unavailable.<br/>↵Please try again later.</p>↵<p>If you are the system administrator of this resource then you should check↵the <a href="http://nginx.org/r/error_log">error log</a> for details.</p>↵<p><em>Faithfully yours, nginx.</em></p>↵</body>↵</html>"
code:1
exception:"http://identify-us-west-2.acrcloud.com/v1/identify"
http_status:500
source:"file:///storage/emulated/0/new2.aac"
target:"http://identify-us-west-2.acrcloud.com/v1/identify"
Transfer error 1 refer to File not Found error, and the response of server is the same that I get when I try to send values without file.
The problem here is when I call Transfer it does´t load the record file