shinfileinputer
v1.0.2
Published
select and access a local file without upload file or files to remote
Downloads
3
Readme
🚀 IT IS A JS MODULE USED IN WEB BROWER
select or access a local file without uploading file or files to remote.
with this api,you can access one or some local files ,and get formate of base64/arraybuffer/text
of files you have selected
HOW TO INSTALL
yarn add shinfileinputer
OR
yarn add git+https://github.com/shinku/shinfileinputer.git
HOW TO USE
import shinfileinputer,{OUTOUTTYPE} from "shinfileinputer";
const inputer = new shinfileinputer();
inputer.start("*",[OUTOUTTYPE.BASE64]).then(res=>{
console.log({res});
//you will get a array of base64,
}
FUNCTIONS
construncor(ismultiple:Boolean=false){
//
}
//const inputer = new shinfileinput();
params | type | ps|
-|-|-
ismultiple | boolean | choose multiple files or just single file.default is false |
start(accepts:string,outputoption:Array<string>):Promise<T>
params | type | ps|
-|-|-
accepts | string | accepts of a input,such as "\*"
or "\*.jppg|*.png"
|
outputoption | Array | default is ["base64"]
or [OUTOUTTYPE.BASE64]
|
setMultiple(val:Boolean):shinfileinput
you wann to change single file choosen to multiple
inputer.setMultiple(true).start("*“).then(......)
OUTOUTTYPE has three types.
- BASE64
- TEXT
- BUFFER means you will get different kinds of format of these files;
import shinfileinput,{OUTOUTTYPE} from "shinfileinputer";
const inputer = new shinfileinputer();
inputer.start("*",[OUTOUTTYPE.BASE64]).then(res=>{
console.log({res});
//[{file:File,datas:[{data:xxxxxxx,type:"base64"}]}]
//get base64content and also you will get the file
}
....
inputer.start("*",[OUTOUTTYPE.BASE64,OUTOUTTYPE.BUFFER]).then(res=>{
console.log({res});
// //[{file:File,datas:[{data:xxxxxxx,type:"base64"},{data:xxxxxxx,type:"arraybuffer"}]}]
//get base64content and also you will get the file
}
EXAMPLE: choose a image from local and put it into a Image Element
import shinfileinput,{OUTOUTTYPE} from "shinfileinputer";
const inputer = new shinfileinput();
inputer.start("image/gif, image/jpeg",[OUTOUTTYPE.BASE64]).then(res=>{
//console.log({res});
let {datas} = res[0];
const image = new Image();
image.src = datas[0]['data'];
document.body.appendChild(image);
}