javascript - 如何在 Ionic-Angular 应用程序中保存图像(Base64 字符串)
问题描述
我在 azure 中部署了一个后端 rest api。
Angular/Ionic App --> Rest call --> Rest API
Angular/Ionic App <--- image (base64 string) --- Rest API
场景:我在应用程序的多个页面中使用此图像(编码为 base64 字符串),我不想多次调用休息。
离子/角度的当前实现:
export class LoginVerificationService {
constructor(private httpClient: HttpClient,
public router: Router,
**@Inject(SESSION_STORAGE) private storage: StorageService,**
private endpoints: EndpointsConstantsService
) {
}
//method that saves the values in session
setSession(userEmail: string,username:string, age:string, image: string) {
this.storage.set(this.endpoints.SESSION_EMAIL, userEmail);
this.storage.set(this.endpoints.SESSION_AGE, age);
this.storage.set(this.endpoints.SESSION_IMAGE, image);
this.storage.set(this.endpoints.SESSION_USERNAME, username);
}
我可以保存姓名和年龄,但是当我尝试保存 base64 图像时应用程序崩溃。还有其他方法可以实现吗?
解决方案
推荐阅读
- firebase - 优化 7 天动态队列 Firebase BigQuery
- sql - Laravel - 可以通过 Eloquent 关系完成条件连接吗?
- google-sheets - 如何修复此电子表格公式?
- python - 如何在 Pandas 中使用 rstrip 删除列中的部分字符串?
- c++ - 如何防止特定的 QTreeView 分支被拖动?
- c# - 重命名 C# windows 窗体 listBox 上列出的文件
- php - 将帖子插入到查询 wordpress 的末尾
- java - 添加内容窗格时正在创建新的 JFrame
- c# - 剃刀页面和服务器方法
- java - 使用 Array 或 String 解析 JSON 实例类型