Technologie-Visao / ckeditor5-video

Other
28 stars 27 forks source link

Issue with Simple Upload Adapter #14

Closed anhtai1907 closed 3 years ago

anhtai1907 commented 3 years ago

Thanks for your amazing plugin, but I have an issue when upload video with the simple upload adapter. Simple Upload Adapter will create an image tag with src is url property responded from upload endpoint. After upload, I inspect element and see that source attribute in video tag always use base64 value.

Am I wrong in configuration?

And another issue is getting data. I use function getData() of editor instance, it can get data but the src attribute is always null.

image

Thank you!

alexdaube commented 3 years ago

Hey @anhtai1907, I am sorry to say that I have never tried this plugin with the SimpleUploadAdapter plugin. Perhaps it would be worth exploring.

I roll my ownUploadAdapter as it is pretty simple and it better suits my needs. It would looks something like:

class UploadAdapter {
  constructor(public loader: any) {
    this.loader = loader;
  }

  public upload() {
    this.loader.uploaded = false;

    const uploadFile = async (file: any) => {
      await UploadService.uploadFile(file);

      this.loader.uploaded = true;

      return { default: `${storageSession.url}${storageSession.fields.key}` };
    };

    return this.loader.file.then((file: any) => uploadFile(file));
  }

  public abort() {
    return Promise.reject();
  }

Then in my React implementation of my custom build which includes this plugin I

<CKEditor
      editor={MyCustomClassicEditorBuild}
      onReady={(editor: any) => {
        editor.plugins.get('FileRepository').createUploadAdapter = (
          loader: any,
        ) => {
          return new UploadAdapter(loader);
        };
      }}
   ...
  />

I hope the code I provided can help you...