blob

umeditor实现ctrl+v粘贴word图片并上传

╄→гoц情女王★ 提交于 2019-12-04 06:55:09
图片的复制无非有两种方法,一种是图片直接上传到服务器,另外一种转换成二进制流的base64码 目前限chrome浏览器使用 首先以um-editor的二进制流保存为例: 打开umeditor.js,找到UM.plugins['autoupload'],然后找到autoUploadHandler方法,注释掉其中的代码。 加入下面的代码: //判断剪贴板的内容是否包含文本 //首先解释一下为什么要判断文本是不是为空 //在ctrl+c word中的文字或者图片之后会返回1种(image/png)或者4种type(text/plain,text/html,text/rtf,image/png)类型的对象 //为了兼容4种格式的情况,做了如下的判断 //如下代码:e.originalEvent.clipboardData.items获得剪贴板的内容 //当粘贴了文本之后text是不为空的,同时也会返回当前文本的图片类型 //如果有文字的话不做任何的处理,如果只粘贴图片的话文本一定是空的,包括复制的桌面图片或者截图的图片 var text = e.originalEvent.clipboardData.getData("text"); if(text == ""){ var items=e.originalEvent.clipboardData.items; for (var i = 0,

JS实现富文本粘贴图片

独自空忆成欢 提交于 2019-12-04 06:37:55
1.实现原理 利用html中 contenteditable 属性+JS判断 2.代码 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <div class="editable" id="richedit" contenteditable>111111111</div> <script> //监听粘贴事件 document.querySelector('#richedit').addEventListener('paste', function (e) { var cbd = e.clipboardData; console.log(cbd) var ua = window.navigator.userAgent; if (!(cbd && cbd.items)) { return; } //判断浏览器 if (cbd.items && cbd.items.length === 2

The specified container does not exist

对着背影说爱祢 提交于 2019-12-04 06:20:59
Am stuck with this error The specified container does not exist. let me explain, CloudBlobClient blobStorage = GetBlobStorage("upload"); CloudBlockBlob blob = BlobPropertySetting(blobStorage, Guid.NewGuid().ToString().ToLower() + Path.GetExtension(file.FileName)); blob.UploadFromStream(file.InputStream); public static CloudBlobClient GetBlobStorage(string cloudBlobContainserName) { CloudBlobClient blobStorage; try { var storageAccount = CloudStorageAccount.FromConfigurationSetting("StorageConnectionString"); blobStorage = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container =

ue/um-editor实现word图片复制

爷,独闯天下 提交于 2019-12-04 06:20:26
图片的复制无非有两种方法,一种是图片直接上传到服务器,另外一种转换成二进制流的base64码 目前限chrome浏览器使用 首先以um-editor的二进制流保存为例: 打开umeditor.js,找到UM.plugins['autoupload'],然后找到autoUploadHandler方法,注释掉其中的代码。 加入下面的代码: //判断剪贴板的内容是否包含文本 //首先解释一下为什么要判断文本是不是为空 //在ctrl+c word中的文字或者图片之后会返回1种(image/png)或者4种type(text/plain,text/html,text/rtf,image/png)类型的对象 //为了兼容4种格式的情况,做了如下的判断 //如下代码:e.originalEvent.clipboardData.items获得剪贴板的内容 //当粘贴了文本之后text是不为空的,同时也会返回当前文本的图片类型 //如果有文字的话不做任何的处理,如果只粘贴图片的话文本一定是空的,包括复制的桌面图片或者截图的图片 var text = e.originalEvent.clipboardData.getData("text"); if(text == ""){ var items=e.originalEvent.clipboardData.items; for (var i = 0,

How to load large local files using JavaScript?

喜你入骨 提交于 2019-12-04 06:06:28
问题 Is there a way to handle very large files(like 2GB and over) locally in JavaScript without crashing the browser? *I am aware of the input tag and the FileReader API, but it seems there is nothing like Node.js streams. 回答1: FileReader enables you to read contents of files asynchronously. With respect to large file (2GB in your case), you can use function/method FileReader.readAsArrayBuffer() to read a certain chunk size of a file in the memory hence this won't crash your browser, this blog is

Better way to insert blob into MySQL with PHP

孤街醉人 提交于 2019-12-04 05:54:09
I am working on a system where I insert files into the database. There are two ways how I am able to insert blob into DB, so I'm curious which one is better. The first is to get the content and then bind parameter of content as a string when inserting: $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); ... $prep_stmt = "INSERT INTO dokumenty (name, size, type, content, autor, poznamka) VALUES (?, ?, ?, ?, ?, ?)"; $stmt = $mysqli->prepare($prep_stmt); $stmt->bind_param('sissis',$fileName,$fileSize,$fileType,$content,$user_id,

Images Created with C# - How to Insert them in BLOB via SQL

依然范特西╮ 提交于 2019-12-04 05:32:46
问题 Let's say if I capture a screen shot. There is my code for it int sWidth = 1600, sHeight = 1200; Bitmap B_M_P = Bitmap(sWidth, sHeight); Graphics gfx = Graphics.FromImage((Image)B_M_P); gfx.CopyFromScreen(0, 0, 0, 0, new Size(screenWidth, screenHeight)); B_M_P.Save("img.jpg", ImageFormat.Jpeg); instead of saving this to an Image, i wanna be able to send this to my SQL or MySQL and store them in the database as BLOB. i know the LINQ as well to query the DB. What i don't know is the

Converting a BlobBuilder to string, in HTML5 Javascript

£可爱£侵袭症+ 提交于 2019-12-04 05:25:42
问题 function blobToString(blob) { var reader = new FileReader(); var d = ""; reader.onloadend = function() { d.callback(reader.result); console.log(reader.result); }; reader.readAsText(blob); return d; }; The above code does not work, but I guess my intentions are clear, I want to convert some binary data(WebKitBlobBuilder) to a string. Also the "console.log(reader.result);" doesn't display anything. 回答1: Check out http://blog.ericzhang.com/state-of-binary-in-the-browser/ and his binary.js

Store very long text: BLOB or TEXT

白昼怎懂夜的黑 提交于 2019-12-04 04:58:08
问题 I have several texts which are very long (tens of thousands of characters). Which is the best option to store such texts in SQLite: as TEXT or as BLOB ? 回答1: In SQLite's database file format, TEXT and BLOB values are stored in exactly the same way. The only difference is that the bytes of a TEXT value are assumed to be valid UTF-8. 回答2: Answer: TEXT BLOB is good only for binary files and generally storing any binary data (images, songs, etc) in a database is not a good idea and is to be done

Angular2: How to handle a async image (blob) request?

三世轮回 提交于 2019-12-04 04:25:56
I am trying to request a image via a secured api. At the moment I got the following to work (see all the resources I use below. import { AssetsService } from '../../services/AssetsService'; import { Component } from '@angular/core'; @Component({ templateUrl: 'home.html', }) export class HomePage { public img; constructor( public assets_service: AssetsService ) { } public async ionViewDidEnter() { this.img = await this.assets_service.picture_request('test.png'); } } My view <img [src]="img | safe" /> Now I've seen the async pipe that looks promising. As you might have guessed, I really don't