我正在处理应用程序女巫,我需要发送多个图像,
我想知道是否可以通过文件传输插件发送多个图像,
这是我的代码:
const options: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.FILE_URI,
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY
}
this.camera.getPicture(options).then((imageData2) => {
this.imageURI2 = imageData2;
}, (err) => {
console.log(err);
});
上传
const fileTransfer: FileTransferObject = this.transfer.create();
let options: FileUploadOptions = {
fileKey: 'file',
fileName: 'name.jpg',
headers: {
Connection: "close"
}
}
options.chunkedMode = false;
if(this.imageURI1 != null){
fileTransfer.upload(this.imageURI1,
'https://test.test.com/uplaodphoto.php', options)
.then((data) => {
alert("success");
this.imageFileName1 =
"https://test.test.com/images/name.jpg"
}, (err) => {
alert("error"+JSON.stringify(err));
});
答案 0 :(得分:0)
用户图像选择器插件Cordova Image Picker
用法:
for (audio in medias) {
var file = File(audio.file_name)
var mimeType = ""
var parameter_name = ""
if (step == step_audio_send) {
mimeType = "audio/*"
parameter_name = "audio_recording"
}
val filePart = MultipartBody.Part.createFormData(parameter_name, file.name, RequestBody.create(MediaType.parse(mimeType), file))
var call: retrofit2.Call<JSONObject>? = null
call = surveyApi.saveSurveyAudio("JWT " + AppPreferences.getString(user_id, "")!!,
audio.submitted_survey_id, audio.q_id,
audio.repeatable_id,
audio.audio_marker, filePart)
try {
var response = call!!.execute()
if (response.isSuccessful) {
mySurveyViewModel.incrementSurveyMediaCount(audio.submitted_survey_id)
}
} catch (ex: Exception) {
ex.printStackTrace()
}
}