Giter Site home page Giter Site logo

readbase64txt's Introduction

功能:

  • 图片转base64
  • 数据导入txt并生成文件
  • 读取txt数据, 并通过编译base64数据转为blob图片
  • nginx配置代理路径

效果

浏览器并未下载jpg格式图片, 而是下载的txt

image-20220402103358923

创建base64的txt格式

上传图片, 将自动生成的txt拷贝到你需要用的地方

txt文件中保存的即为图片的base64数据

编译txt文件, 生成图片数据

## 先通过ajax下载文件
## 然后通过FileReader进行解析txt文件
#### readAsText读取txt文件内容
## 然后将base64转化为blob格式
## 最后通过 URL.createObjectURL 生成图片链接
## 将图片链接绑定到img src即可

#### 另外注意的是, createObjectURL 在不需要的时候需要销毁(使用URL.revokeObjectURL), 防止内存溢出

nginx发布预览

需要发布代理地址, 否则上述功能无法预览(平常开发时正常发布到服务器即可, 测试时可以使用临时nginx代理)

## 1. 下载
http://nginx.org/

## 2. 解压后, 修改配置文件
#### nginx配置文件在 nginx-x.x.x\conf\nginx.conf
http {
     gzip  on;

    #html
    server {
        listen       8888;
        server_name  localhost;

        location / {
            ## root   G:/source/static_cnblog_com;
            root   html;
            index  index.html index.htm n1.html;
        }
        ## 使用/read url时, 会自动引用alias配置的路径
        ## localhost:8888/read/
        location /read {
            alias html/readBase64Txt;
        }
    }

}

readbase64txt's People

Contributors

1322641861 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.