Giter Site home page Giter Site logo

sinaimgmover's Introduction

微博图床一键迁移到阿里云 OSS

今天发现博客上大量图片显示不出来了,打开Chrome控制台一看出现了大量的 403 图片

sina image 403

这就是薅微博图床的羊毛的后果,应该是微博图床这边升级了访问策略,幸运的是直接打开图片地址还是可以访问的,不然就有得ಥ_ಥ了,这么多图片丢失了那就坑爹了,怎么办?迁移呗~~

怎么迁移?把图片一张一张的下载下来,然后换一个存放图片的服务?这未免太麻烦了吧,这么多图片~~~,真是应了那句话:微博图床一时爽,迁移火葬场[奸笑]

于是花了一点点时间写了个小程序来一键将微博图床里面的图片一键迁移到阿里云OSS上面。这个程序使用起来很简单,提供几个阿里云OSS的一些参数即可,比如 bucket、accessKey、accessSecret:

$ ./sinaimgmover -h
Usage of ./sinaimgmover:
  -bucket string
        指定Aliyun  OSS Bucket
  -endpoint string
        OSS Endpoint(不包含http(s)),如:oss-cn-hangzhou.aliyuncs.com (default "oss-cn-beijing.aliyuncs.com")
  -folder string
        Bucket下面的文件夹目录,默认为 images (default "images")
  -key string
        Aliyun OSS Key
  -length int
        指定上传到OSS上面的图片名称长度,默认为6 (default 6)
  -post string
        指定markdown文章路径,默认当前目录 (default "./")
  -secret string
        Aliyun OSS Secret

示例:

$ ./sinaimgmover -bucket=bxdc-static -key=xxxx -secret=xxxx -post=/Users/ych/devs/workspace/www.qikqiak.com/content/page
成功替换了图片:https://ws3.sinaimg.cn/large/006tKfTcgy1g1o2gcoqs2j30u021fe81.jpg
成功替换了图片:https://ws3.sinaimg.cn/large/006tKfTcgy1g1o2gcoqs2j30u0212233.jpg
......

心情舒畅多了~~~

sinaimgmover's People

Contributors

cnych 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.