Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request]: Add backend example of how to use upload plugin #1855

Closed
Tracked by #1948
gregg-cbs opened this issue Sep 24, 2023 · 8 comments
Closed
Tracked by #1948

[Request]: Add backend example of how to use upload plugin #1855

gregg-cbs opened this issue Sep 24, 2023 · 8 comments
Assignees
Labels
issue: docs/code example Issues about incorrect code examples found on docs.strapi.io

Comments

@gregg-cbs
Copy link

Summary

In the documentation for upload plugin:
https://docs.strapi.io/dev-docs/plugins/upload#using-a-provider

There are examples of how to use this via rest api but no examples of how to access or use this plugin from the backend. In a controller of lifecycle.

Why is it needed?

It would be nice to know how to interact with this plugin from code.

Suggested solution(s)

Add a code example of how to access the upload plugin from a controller.

Related issue(s)/PR(s)

No response

@Boegie19
Copy link
Contributor

Boegie19 commented Sep 24, 2023

@gregg-cbs strapi/strapi#15524 is what you are looking for.

Also if you have any more questions.
Stop by for Open Office Hours Mon - Friday 12:30 PM CST
Strapi Community

@gregg-cbs
Copy link
Author

You are a busy person @Boegie19 and I appreciate the response. Hopefully the ability to do this will become available. It would then be nice if the documentation could have an alert that says this is not currently possible?

@Boegie19
Copy link
Contributor

You are a busy person @Boegie19 and I appreciate the response. Hopefully the ability to do this will become available. It would then be nice if the documentation could have an alert that says this is not currently possible?

It is posible if your copy past the util that they wrote there. to transform the data it expects.

@pwizla pwizla self-assigned this Oct 18, 2023
@pwizla pwizla added the issue: docs/code example Issues about incorrect code examples found on docs.strapi.io label Oct 18, 2023
@Boegie19
Copy link
Contributor

@pwizla before we document this strapi would first need to deside to accept the PR or close it.

@pwizla
Copy link
Collaborator

pwizla commented Dec 11, 2023

Hi,
Thanks for reporting. I'm closing this issue but it's included in the meta issue for the Upload plugin (#1948).

@pwizla pwizla closed this as completed Dec 11, 2023
@gregg-cbs
Copy link
Author

Yes it is mentioned there. thank you :)

@Zetjen
Copy link
Contributor

Zetjen commented Mar 10, 2024

Hi, I think would be great to have the following snippet on the upload plugin documentation.

Saving a file on api controller:

async create(ctx) {

  // ...

  const { body, files } = ctx.request;

  const file = files["files.uploadedFile"];

  const createdFiles = await strapi.plugins.upload.services.upload.upload({
    data: {
      fileInfo: {
        name: "Name",
        caption: "Caption",
        alternativeText: "Alternative Text",
      },
    },
    files: file,
  });

  // ...

},
 

#2043

@pwizla
Copy link
Collaborator

pwizla commented Mar 11, 2024

Thank you for the suggestion, @Zetjen. I've merged the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: docs/code example Issues about incorrect code examples found on docs.strapi.io
Projects
None yet
Development

No branches or pull requests

4 participants