0.1.4 • Published 6 years ago

v-cloudinary-upload v0.1.4

Weekly downloads
22
License
-
Repository
-
Last release
6 years ago

Vue Cloudinary Upload

Simple wrapper to upload files using cloudinary api

Usage

Locally

import VCloudinaryUpload from 'v-cloudinary-upload'

export default {
  components: { VCloudinaryUpload }
}

Globally

import Vue from 'vue'
import * as VCloudinaryUpload from 'v-cloudinary-upload'

Vue.use(VCloudinaryUpload)

Examples

Unsigned upload

<v-cloudinary-upload autoUpload accountName="skyatura" preset="foo">
	<button>Click here to select a file</button>
</v-cloudinary-upload>

Unsigned upload with preview

<v-cloudinary-upload autoUpload accountName="skyatura" preset="foo">
	<template slot-scope="props">
		<img :src="props.url" v-if="props.url">
		<button v-else>Click here to select a file</button>
	</template>
</v-cloudinary-upload>

Signed upload

<template>
	<v-cloudinary-upload ref="img" accountName="skyatura" @picked="onPickFile">
		<button>Click here to select a file</button>
	</v-cloudinary-upload>
</template>

<script>
export default {
	methods: {
		async onPickFile() {
			const params = await this.$axios.$get('/upload/userPicture')
			this.$refs.img.upload(params)
		}
	}
}
</script>

Properties

PropertyRequiredTypeDescription
accountNametrueStringYour Cloudinary's account name
autoUploadfalseBooleanIf the component should automatically perform an upload after selecting a file
capturefalseBoolean, StringPassed to the input element. Check this documentation for more details
disabledfalseBooleanIf true, the file picker won't be triggered
fileTypesfalseArray, StringA list of allowed image types. It can be either an array or comma separated. Default: *
presetfalseStringUsed when uploading unsigned pictures. It will be automatically appended to the upload request
tagfalseStringDefines the component wrapper tag. Default: div
uploadParamsfalseObjectAppend extra parameters to the upload request
@picked--EventFired when user chooses a file. It contains: file, name and url (Seeabove for more information)
@uploaded--EventFired after a successful. It contains the response from Cloudinary

Slot scope

PropertyTypeDescription
fileObjectContains the file that will be uploaded
fileReaderObjectContains the result from the file reader
nameStringThe name of the file selected, if available
urlStringThe file encoded in base64 for using in previews
loadingBooleanTrue if the component is currently uploading an image
uploadedObjectThe response from Cloudinary, if available. (Same as the passed to the uploaded event)
0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago