🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@fly_tiger/tiger-upload

Package Overview
Dependencies
Maintainers
3
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fly_tiger/tiger-upload

Now I’m the model of a modern major general / The venerated Virginian veteran whose men are all / Lining up, to put me up on a pedestal / Writin’ letters to relatives / Embellishin’ my elegance and eloquence / But the elephant is in the room / The truth i

latest
npmnpm
Version
1.0.5
Version published
Maintainers
3
Created
Source

ecph上传方法

::: demo

<div>
  <div>
    <el-upload
      action="/"
      :before-upload="beforeUpload"
      >
      <el-button size="small" type="primary">点击上传</el-button>
    </el-upload>
    <el-button @click="handlerPause">暂停</el-button>
    <el-button @click="handlerRun">开始</el-button>
    <div v-for="item in (uploadList || [])">
      <div>{{(item || {}).Location}}</div>
    </div>
    <el-progress style="width: 200px;" :text-inside="true" :stroke-width="24" :percentage="percentage" status="success"></el-progress>
  </div>
</div>

<script>
export default {
   data() {
      return {
        percentage: 0,
        uploadList: [],
        multipartUpload: null,
        awsClient: null
      };
    },
    methods: {
      async handlerRun() {
        const result = await this.multipartUpload.reRun()
        this.uploadList.push(result)
      },
      handlerPause() {
        this.multipartUpload.pause()
      },
      async beforeUpload(file) {
        this.multipartUpload = this.awsClient.multipartUpload({
          file,
          progress: (percent) => {
            this.percentage = percent * 100;
          },
          breakpoint: () => {
            return new Promise((res, rej) => {
              this.$confirm('是否继续上传', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(() => {
                res(true)
              }).catch(() => {  
                res(false)
              });
            })
          }
        })
        const result = await this.multipartUpload.run()
        fetch("http://test-api.flytiger.net/base/sysStorageCeph/anon/add", {
          method:"POST",
          mode: 'cors',
         headers: {
            'Content-Type': 'application/json'
         },
         body:JSON.stringify({
          'etag' : result.ETag,
            'filePath': result.Location
          })
          }).then(response => response.json()).then(json => {})
        this.uploadList.push(result)
        return false;
      }
    },
    mounted() {
      fetch("http://test-api.flytiger.net/base/sysStorageCeph/anon/getCephSignature")
      .then(res => res.json())
      .then(data => {
        const { accessKey: accessKeyId, bucket: Bucket, endpoint, secretKey: secretAccessKey } = data.data;
        this.awsClient = new AWSClient({
          accessKeyId,
          secretAccessKey,
          endpoint: `http://${endpoint}`,
          Bucket
        });
        console.log(this.awsClient)
      })
      console.log(AWSClient)
    }
}
</script>
<style>
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>

:::

FAQs

Package last updated on 28 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts