Ember.js 如何使用ember和RESTful api将图像上载到postgreSQL数据库
我有一个ember应用程序,可以列出使用django rest框架和postgreSQL的Ember.js 如何使用ember和RESTful api将图像上载到postgreSQL数据库,ember.js,django-rest-framework,image-upload,Ember.js,Django Rest Framework,Image Upload,我有一个ember应用程序,可以列出使用django rest框架和postgreSQL的校友的详细信息。我需要上传图像(存储在我的存储器中)以及其他详细信息。我如何在余烬中实现这一点 我可以通过从ember转换为base64并存储编码字符串来完成吗?如果可能,如何使用?您可以将此模块用于此您可以将此模块用于此我可以使用base64编码将图像上载到PostgreSQL。我使用插件将图像转换为base64代码 我在我的add路线中使用了这些代码(请注意,我使用的是pod结构): 模板.hbs &l
校友的详细信息。我需要上传图像(存储在我的存储器中)以及其他详细信息。我如何在余烬中实现这一点
我可以通过从ember转换为base64并存储编码字符串来完成吗?如果可能,如何使用?您可以将此模块用于此您可以将此模块用于此我可以使用base64编码将图像上载到PostgreSQL。我使用插件将图像转换为base64代码
我在我的add
路线中使用了这些代码(请注意,我使用的是pod结构):
模板.hbs
<form {{action "submitAlumni" on="submit"}} class="alumniForm">
<div>{{image-drop image=selectedImage placeholder="Image" helpText="Drop your image here, or click to select"}}</div>
<button class="btn btn-primary" {{action "submitAlumni"}}>Submit</button>
</form>
import Route from '@ember/routing/route';
export default Route.extend({
});
import Controller from '@ember/controller';
import { set } from '@ember/object';
export default Controller.extend({
image: null,
actions: {
submitAlumni() {
let image = this.get('selectedImage');
var onFail = function(response) {
alert(response);
};
const alumni = this.get('store').createRecord('alumni', {
image: image,
});
alumni.save().then(() => {
this.transitionToRoute('alumnis.show', alumni.id)
}, onFail);
},
}
});
controller.js
<form {{action "submitAlumni" on="submit"}} class="alumniForm">
<div>{{image-drop image=selectedImage placeholder="Image" helpText="Drop your image here, or click to select"}}</div>
<button class="btn btn-primary" {{action "submitAlumni"}}>Submit</button>
</form>
import Route from '@ember/routing/route';
export default Route.extend({
});
import Controller from '@ember/controller';
import { set } from '@ember/object';
export default Controller.extend({
image: null,
actions: {
submitAlumni() {
let image = this.get('selectedImage');
var onFail = function(response) {
alert(response);
};
const alumni = this.get('store').createRecord('alumni', {
image: image,
});
alumni.save().then(() => {
this.transitionToRoute('alumnis.show', alumni.id)
}, onFail);
},
}
});
我能够使用base64编码将图像上传到PostgreSQL。我使用插件将图像转换为base64代码
我在我的add
路线中使用了这些代码(请注意,我使用的是pod结构):
模板.hbs
<form {{action "submitAlumni" on="submit"}} class="alumniForm">
<div>{{image-drop image=selectedImage placeholder="Image" helpText="Drop your image here, or click to select"}}</div>
<button class="btn btn-primary" {{action "submitAlumni"}}>Submit</button>
</form>
import Route from '@ember/routing/route';
export default Route.extend({
});
import Controller from '@ember/controller';
import { set } from '@ember/object';
export default Controller.extend({
image: null,
actions: {
submitAlumni() {
let image = this.get('selectedImage');
var onFail = function(response) {
alert(response);
};
const alumni = this.get('store').createRecord('alumni', {
image: image,
});
alumni.save().then(() => {
this.transitionToRoute('alumnis.show', alumni.id)
}, onFail);
},
}
});
controller.js
<form {{action "submitAlumni" on="submit"}} class="alumniForm">
<div>{{image-drop image=selectedImage placeholder="Image" helpText="Drop your image here, or click to select"}}</div>
<button class="btn btn-primary" {{action "submitAlumni"}}>Submit</button>
</form>
import Route from '@ember/routing/route';
export default Route.extend({
});
import Controller from '@ember/controller';
import { set } from '@ember/object';
export default Controller.extend({
image: null,
actions: {
submitAlumni() {
let image = this.get('selectedImage');
var onFail = function(response) {
alert(response);
};
const alumni = this.get('store').createRecord('alumni', {
image: image,
});
alumni.save().then(() => {
this.transitionToRoute('alumnis.show', alumni.id)
}, onFail);
},
}
});
我可以用同样的方法从本地存储转换图像文件吗?是的,如果你有一个文件,你可以将其转换为base64。我可以用同样的方法从本地存储转换图像文件吗?是的,如果你有一个文件,你可以将其转换为base64。你尝试了什么吗?@JPG我可以用addondid将图像编码为base64。你尝试了什么吗?@JPG我是能够使用插件将图像编码到base64