将视频保存在本地存储中 [英] Save a video in local storage
问题描述
Atm我将简单的字符串保存在本地存储中.但是现在的问题是我想将视频/图像保存到本地存储中.但是由于localStorage仅支持字符串,所以我看不到这是怎么可能的.
Atm I'm saving simple strings in local storage. But the problem is now I want to save videos/images to local storage. But since localStorage only supports strings I don't see how this would be possible.
如果您可以提供很好的代码示例!
If you could provide with code example that would be good!
<form #userForm = "ngForm" (ngSubmit)="onSubmit(userForm.value)">
<div class="form-group">
<label for="exampleInputFile">File input</label>
<input type="file" class="form-control-file" id="image" aria-describedby="fileHelp" accept="image/*, video/*" ng name="image" ngModel>
<small id="fileHelp" class="form-text text-muted"></small>
</div>
</form>
add-profile.components.ts
add-profile.components.ts
onSubmit(value: any){
localStorage.setItem(this.getId(), JSON.stringify(value));
}
推荐答案
https://github.com/ninjatronic/angular-base64
使用类似的方法将图像转换为CodeCaster所说的base64. 但这是一个坏主意,您可能会用完空间,而且还是无法正常工作.如果我没记错(仔细检查),但是每个本地存储10mb,那么视频就不会保存在那里(也许是质量低的视频).
Use something like this to convert the image to base64 as CodeCaster said. But it's a bad idea, and you may run out of space and it won't work anyways. If I remember correctly (double check) but it's 10mb per localstorage so a video won't save there (tiny low quality video maybe).
您为什么不临时使用本地数据库?
Why don't you use a local db temporarily?
这篇关于将视频保存在本地存储中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!