Skip to content

Commit

Permalink
Upgrade to Bytescale Upload Widget
Browse files Browse the repository at this point in the history
  • Loading branch information
ljwagerfield committed Sep 17, 2023
1 parent dd21f39 commit 7bbfaf4
Show file tree
Hide file tree
Showing 16 changed files with 502 additions and 224 deletions.
1 change: 1 addition & 0 deletions .github/assets/bytescale-upload-widget-jquery.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
env:
SLACK_CHANNEL: deployments
SLACK_COLOR: "#17BB5E"
SLACK_TITLE: "Built: jquery-uploader :rocket:"
SLACK_TITLE: "Built: @bytescale/upload-widget-jquery :rocket:"
SLACK_FOOTER: "This package was successfully built."
MSG_MINIMAL: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
Expand All @@ -67,7 +67,7 @@ jobs:
env:
SLACK_CHANNEL: deployments
SLACK_COLOR: "#BB1717"
SLACK_TITLE: "Failed: jquery-uploader :boom:"
SLACK_TITLE: "Failed: @bytescale/upload-widget-jquery :boom:"
SLACK_FOOTER: "No packages published."
MSG_MINIMAL: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
8 changes: 4 additions & 4 deletions BUILD.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Building From Source

This repository contains a hot-reloading sandbox for developing the `@upload-io/jquery-uploader` NPM package.
This repository contains a hot-reloading sandbox for developing the `@bytescale/upload-widget-jquery` NPM package.

## Prerequisites

Expand All @@ -16,8 +16,8 @@ This repository contains a hot-reloading sandbox for developing the `@upload-io/
### 1. Clone

```shell
git clone git@github.com:bytescale/jquery-uploader.git
cd jquery-uploader
git clone git@github.com:bytescale/bytescale-upload-widget-jquery.git
cd bytescale-upload-widget-jquery
```

### 2. Setup Environment
Expand All @@ -38,6 +38,6 @@ npm install
npm start
```

The above launches a **hot-reloading** server on `http://127.0.0.1:3050` that uses `@upload-io/jquery-uploader` from source.
The above launches a **hot-reloading** server on `http://127.0.0.1:3050` that uses `@bytescale/upload-widget-jquery` from source.

_Please ensure nothing else is running on TCP port `3050`_.
110 changes: 110 additions & 0 deletions MIGRATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Migration Guide

## From jQuery Uploader (`@upload-io/jquery-uploader`)

Steps:

1. Install `@bytescale/upload-widget-jquery`
2. Uninstall `@upload-io/jquery-uploader` and `uploader`
3. Replace `"@upload-io/jquery-uploader"` with `"@bytescale/upload-widget-jquery"` in your `import` statements.
4. Replace `uploader` with `upload-widget` in all CSS class name overrides (if you have any).
5. Remove `uploader` (from imports and props)
6. Remove `$.uploader.init(...)`
7. Replace `.uploader({...})` with `.bytescaleUploadWidget({...})`
8. Add `apiKey` as a field to the object passed to the `bytescaleUploadWidget` method (add it if you don't have one).

### Before

```html
<template>
<button @click="uploadFile">Upload a file...</button>
</template>

<script lang="ts">
import { Uploader } from "uploader";
import { openUploadModal } from "@upload-io/jquery-uploader";
import type { UploadWidgetConfig, UploadWidgetResult } from "uploader";
import type { PreventableEvent } from "@upload-io/jquery-uploader";
// Create one instance per app. (Get API keys from Bytescale)
const uploader = Uploader({
apiKey: "free"
});
// See "customization" below.
const options: UploadWidgetConfig = {
multi: true
};
export default {
name: "App",
methods: {
uploadFile(event: PreventableEvent) {
openUploadModal({
event,
uploader,
options,
onComplete: (files: UploadWidgetResult[]) => {
if (files.length === 0) {
alert("No files selected.");
} else {
alert(files.map(f => f.fileUrl).join("\n"));
}
}
})
}
}
};
</script>
```

### After

```html
<template>
<button @click="uploadFile">Upload a file...</button>
</template>

<script lang="ts">
import { openUploadModal } from "@bytescale/upload-widget-jquery";
import type { UploadWidgetConfig, UploadWidgetResult } from "@bytescale/upload-widget";
import type { PreventableEvent } from "@bytescale/upload-widget-jquery";
// Full Configuration:
// https://www.bytescale.com/docs/upload-widget#configuration
const options: UploadWidgetConfig = {
apiKey: "free", // Get API keys from: www.bytescale.com
maxFileCount: 10
};
export default {
name: "App",
methods: {
uploadFile(event: PreventableEvent) {
openUploadModal({
event,
options,
onComplete: (files: UploadWidgetResult[]) => {
if (files.length === 0) {
alert("No files selected.");
} else {
alert(files.map(f => f.fileUrl).join("\n"));
}
}
})
}
}
};
</script>
```

## See also

Bytescale migration guides listed below:

- [Migrating from `upload-js` to `@bytescale/sdk`](https://github.com/bytescale/bytescale-javascript-sdk/blob/main/MIGRATE.md)
- [Migrating from `uploader` to `@bytescale/upload-widget`](https://github.com/bytescale/bytescale-upload-widget/blob/main/MIGRATE.md)
- [Migrating from `jquery-uploader` to `@bytescale/upload-widget-jquery`](https://github.com/bytescale/bytescale-upload-widget-jquery/blob/main/MIGRATE.md)
- [Migrating from `angular-uploader` to `@bytescale/upload-widget-angular`](https://github.com/bytescale/bytescale-upload-widget-angular/blob/main/MIGRATE.md)
- [Migrating from `@upload-io/vue-uploader` to `@bytescale/upload-widget-vue`](https://github.com/bytescale/bytescale-upload-widget-vue/blob/main/MIGRATE.md)
- [Migrating from `@upload-io/jquery-uploader` to `@bytescale/upload-widget-jquery`](https://github.com/bytescale/bytescale-upload-widget-jquery/blob/main/MIGRATE.md)
Loading

0 comments on commit 7bbfaf4

Please sign in to comment.