External module: file文件操作
Index
Functions
Functions
get_file_url
▸ get_file_url(productid: string
, field_name: string
, data: object
): object
Defined in file/get-file-url.ts:20
获取图片地址
see: api
example:
import get_files_url from '@dfeidao/atom-web/file/get-file-url';
const data={ file_id : '1' };
const res = get_files_url('by_jxc','file_id', data);
Parameters:
Name | Type | Description |
---|---|---|
productid | string |
产品id |
field_name | string |
图片id的字段名 |
data | object |
数据 |
Returns: object
get_files_url
▸ get_files_url(productid: string
, field_name: string
, dataArr: Array
<object
>): object
[]
Defined in file/get-files-url.ts:23
获取多个图片地址
see: api
example:
import get_files_url from '@dfeidao/atom-web/file/get-files-url';
const dataArr=[
{file_id:'1'},
{file_id:'2'},
{file_id:'3'}]
const res = get_files_url('by_jxc','file_id', dataArr);
Parameters:
Name | Type | Description |
---|---|---|
productid | string |
产品id |
field_name | string |
图片id的字段名 |
dataArr | Array <object > |
数据 |
Returns: object
[]
img2base64
▸ img2base64(node: HTMLInputElement
): Promise
<string
>
Defined in file/img2base64.ts:17
将图片转成base64
see: api
example:
import img2base64 from '@dfeidao/atom-web/file/img2base64';
import get_dom_by_id from '@dfeidao/atom-web/ui/get-dom-by-id';
const node = get_dom_by_id(fd.data.node, 'node') as HTMLInputElement;
const base = await img2base64(input);
Parameters:
Name | Type | Description |
---|---|---|
node | HTMLInputElement |
fileinput结点对象 |
Returns: Promise
<string
>
read
▸ read(el: HTMLInputElement
, encoding?: string
): Promise
<Object
>
Defined in file/read-text.ts:18
读取文本文件的内容
see: api
example:
import read from '@dfeidao/atom-web/file/read-text';
import get_dom_by_id from '@dfeidao/atom-web/ui/get-dom-by-id';
const el = get_dom_by_id(fd.data.node, 'el') as HTMLInputElement;
const res = await read(el);
Parameters:
Name | Type | Default value | Description |
---|---|---|---|
el | HTMLInputElement |
- | input节点 |
Default value encoding |
string |
"utf8" | 文件的编码格式(默认是utf8,还有其他格式,比如ascii、ansi、gbk等格式) |
Returns: Promise
<Object
>
remove
▸ remove(productid: string
, file_id: string
[]): Promise
<boolean
>
Defined in file/remove.ts:20
根据文件名删除文件服务器上的文件
see: api
requires: 使用本原子操作需要在package.json中devDependencies下加入"@dfeidao/send-msg":"@version";
@version 为该模块的版本号,可以在这里查询
example:
import remove from '@dfeidao/atom-web/file/remove';
const res = await remove( 'by_jxc', '6f0a406d-1d5a-4694-9fd5-11ce55211aab.jpg');
Parameters:
Name | Type | Description |
---|---|---|
productid | string |
产品id |
file_id | string [] |
要删除的文件id,上传时返回的filename |
Returns: Promise
<boolean
>
reupload
▸ reupload(productid: string
, file_id: string
, node: HTMLInputElement
): Promise
<IFileDoc
>
Defined in file/reupload.ts:40
将一个input为file的文件的文件内容转换为base64格式并上传到服务器
see: api
requires: 使用本原子操作需要在package.json中devDependencies下加入"@dfeidao/send-msg":"@version";
@version 为该模块的版本号,可以在这里查询
example:
import reupload from '@dfeidao/atom-web/file/reupload';
import get_dom_by_id from '@dfeidao/atom-web/ui/get-dom-by-id';
const node = get_dom_by_id(fd.data.node, 'node') as HTMLInputElement;
const res = await reupload( 'by_jxc', '6f0a406d-1d5a-4694-9fd5-11ce55211aab.jpg', node);
Parameters:
Name | Type | Description |
---|---|---|
productid | string |
webtest |
file_id | string |
要删除的文件id,上传时返回的filename |
node | HTMLInputElement |
fileinput结点对象 |
Returns: Promise
<IFileDoc
>
upload
▸ upload(productid: string
, node: HTMLInputElement
): Promise
<Object
>
Defined in file/upload-input.ts:21
将一个input中的文件上传到服务器(支持多文件上传)
see: api
requires: 使用本原子操作需要在package.json中devDependencies下加入"@dfeidao/send-msg":"@version";
@version 为该模块的版本号,可以在这里查询
example:
import upload from '@dfeidao/atom-web/file/upload-input';
import get_dom_by_id from '@dfeidao/atom-web/ui/get-dom-by-id';
const node = get_dom_by_id(fd.data.node, 'node') as HTMLInputElement;
const res = await upload('192.168.40.196', 'by_jxc', node);
Parameters:
Name | Type | Description |
---|---|---|
productid | string |
webtest |
node | HTMLInputElement |
fileinput结点对象 |
Returns: Promise
<Object
>
upload
▸ upload(productid: string
, node: HTMLInputElement
): Promise
<IFileDoc
>
Defined in file/upload.ts:37
将一个input为file的文件的文件内容转换为base64格式并上传到服务器
see: api
requires: 使用本原子操作需要在package.json中devDependencies下加入"@dfeidao/send-msg":"@version";
@version 为该模块的版本号,可以在这里查询
example:
import upload from '@dfeidao/atom-web/file/upload';
import get_dom_by_id from '@dfeidao/atom-web/ui/get-dom-by-id';
const node = get_dom_by_id(fd.data.node, 'node') as HTMLInputElement;
const res = upload('by_jxc', node);
Parameters:
Name | Type | Description |
---|---|---|
productid | string |
webtest |
node | HTMLInputElement |
fileinput结点对象 |
Returns: Promise
<IFileDoc
>