Strapi: Upload files to a specific media library folder using strapi upload api - strapi

I'm trying to upload files to Strapi's media library through its upload api.
Right now, all the files are getting uploaded to "API Uploads" folder.
Is there a way to upload the files to folder of my choice?
I couldn't find any details about it in the documentation.

Currently this is not possible, according to the documentation last updated on December 14, 2022: https://docs.strapi.io/developer-docs/latest/plugins/upload.html#endpoints
Folders are an admin panel feature and are not part of the REST or the GraphQL API. Files uploaded through the REST or GraphQL API are located in the automatically created "API Uploads" folder.
There is a feature request on this, so users can vote: https://feedback.strapi.io/feature-requests/p/support-for-media-folders-in-the-content-api
(In the feature request, there's discussion on how to do it in a hacky way, did not test it myself)
Also, If you have to create many folders (like I had to), you would have to do it manually through the interface, but my solution was to automate it with a script that creates them directly onto the db table.

Related

Importing files from Dropbox using API v2 to a server(web-to-web)

I am trying to implement Dropbox on my website and so far I've been able to upload, fetch file metadata, user details and also download the file on my local machine(using the Dropbox API v2).
But, I would like to import the file directly from Dropbox and upload it to the server to be processed further....I'm able to generate the link for the chosen file using the "Chooser"
Dropbox API explorer lists all the possible APIs dropbox can provide.
To build the website I'm using laravel 5.6.17
Your help would be much appreciated. Thanks in advance

Restrict file types in Strapi file upload

I'm using Strapi to create an API for a project and one content type has a media field called "image." For obvious reasons, I'd like to restrict the types of file uploads to just images. It seems like it should be easy, but I don't see how to do that anywhere in the documentation. Does anyone else have a solution?

How to program an event that detects when a file is upload to Yammer?

Event That is thrown when file is upload to Yammer.I am not able to do it with Yammer javascript sdk.
You don't specify how quickly you need to respond to a file being uploaded. The Data Export API allows you to download just the files.csv which includes a list of files uploaded. You can consume this to know which new files have been uploaded.

How can I upload multiple files from urls directly to cloud storage

I've tried some of the services out there, including droplet, ctrlq.org/save, and some other sites that support directly fetching a file from a url and uploading it to dropbox, google drive and the like. Without the user having to store the file on a local disk.
Now the problem is none of these services support multiple urls or batch uploading, but I have quite a few urls and I really need a service where I can put them in, split them with enters or semicolons, and have the files uploaded to dropbox.(or any other cloud storage)
Any help would be gladly appreciated.
The Dropbox Saver JavaScript control allows you to save up to 100 files to the user's Dropbox in one shot. You'll need to programmatically create the button using Dropbox.createSaveButton as explained in the linked page.
It seems like the 100-file limit (at any one time) is universal, but you might find that it isn't the case when using the DropBox REST API. It looks possible to do this with NodeJS server side (OAuth and posts) or Javascript client side (automating FileReader). I'll review and try to add content so these aren't just links.
If you can leave a page open for about 20 minutes due to "technical limitations", the dropbox should be loadable 100-at-a-time like that, assuming each upload takes less than 2 seconds; it's an easy hook to add a progress indicator.
If you're preloading the dropbox once yourself or the initial load is compatible with manual action, perhaps mapping a drive and trying to unzip an archive of your links to it would work. If your list of links isn't extremely volatile then the REST API could be used to synchronize changes.
Edit: Forgot to include this page on CloudConvert, which unzips archives containing up to 100 files into DropBox. Your use case doesn't seem to include retrieving the actual content at your servers (generated zip files), sending the automation list to the browser and then having the browser extract to dropbox, but it's another option.
The Dropbox API now offers the ability to save a file into Dropbox directly via a URL. There's a blog post about it here:
https://blogs.dropbox.com/developers/2015/06/programmatically-saving-a-url-to-dropbox/
The documentation can be found here:
https://www.dropbox.com/developers/core/docs#save-url

Retrieve the user response saved in a file in an app hosted on Cloudbees

I have hosted a Tomcat application on CloudBees which allows users to edit some XML and saves them. I need to download and save these files locally for my personal usage. However I could not find a way to do this. I tried the 'download source' option but it downloads the original files that I had uploaded and not the edited versions. However my application is able to access the edited versions (and so clearly everything is being saved all right). Getting these files back is extremely critical and necessary for me and is, in fact, the whole motive of this app. Kindly tell if there is some way to get back the files in CloudBees or any other free Java hosting site which would allow me to do it.
It's not very clear from your question how your app is currently dealing with these files, but I'll take a swing at providing some general info.
To support editing and downloading of files, your app design would need to address the following issues:
How do users edit/upload the changed XML?
Where does your app store the changed XML?
How does your app retrieve the edited XML and make it available for download?
For #1, you will need to provide an edit or upload interface in your app for manipulating the XML files. I'm assuming this is something your app has already solved using a form of some kind.
For #2, you need to pick an approach for storing the files that is appropriate for app's needs and the runtime environment where your app will be deployed. For instance, on CloudBees (or most other CLoud platforms), it's important to understand that the local filesystem of the app can be used for temporary storage, but it is not clustered and it will be wiped away each time the app is updated or restarted. If these XML files need to be available forever, you will need to store them in a persistent location that is external to the application's runtime instance. Most developers use databases (such as the CloudBees MySQL service) to store persistent data in this way. In general, your app can store these files anywhere, but your app needs to manage how to store them, and how to retrieve them later.
For #3, to allow a user to download the changed files, you will need to implement your own mechanism for retrieving the file from its persistent location, and then send it back to the user's browser. If you want something like right-click "Save As" to work, then your app will just need to support a URL that can display the edited XML file directly in the browser. If your app then provides a link to that URL, users can download it using RightClick+SaveAs. If you want the user to be able to click on a button/link and trigger a Save As dialog automatically, then you'd need to write a URL handler (Servlet) that serves the XML content up using a Content-Disposition header (see this StackOverflow article). This header will tell the browser that the file is supposed to be saved to disk, and allows you to provide a default file name.

Resources