Closed matepaiva closed 2 years ago
As I can see from Strapi Plugin Upload, we can use 'hash' file property to determine original file locations: https://github.com/strapi/strapi/blob/master/packages/core/upload/server/services/upload.js#L85 And I see that's true for my Strapi projects (also I use AWS S3 plugin). So we can use any names, captions and alts.
Well, file hash is a slugified pathname without extension + some random string. Slugify function removes some characters from the pathname, e.g. underscore. So '/abc/_.jpg'
and '/abc/_____.jpg'
both become just 'abc'. That makes impossible to use 'hash' as a real pathname hash :(
Anyway here is my working example with name, alt, caption and search by hash: https://github.com/Alex01d/strapi-plugin-import-export-entries/tree/search-by-hash . I won't create PR from this branch, BTW I decided not to use filenames from Strapi in my frontends, filenames here are system things.
Also a version with alts and captions is on the way.
Is your feature request related to a problem? Please describe. I need to import my multimedia files from an old system to strapi. Today it's possible to import it, but you can't maintain the ID reference, nor the caption, name, or alternative text.
Describe the solution you'd like Today if I import the following
media
object:[ { "title": "test", "media": { "id": 31896, "url": "http://www.anteprojectos.com.pt/wp-content/uploads/2010/03/35850a.jpg", "name": "blablabla.jpg" } } ]
* the id is not being respected. As I passed the url, it ignores the id, but it would be great to save that media with that id, although I am not sure that this is possible. * The name is not being respected. * it would be good to have the ability to set the alternative text and caption. * Also, it's only possible to import media if it is related to other content. I wish I could import media directly to `upload` or `file` content-type.
Describe alternatives you've considered I tried to import the files directly to the
File
content-type (via the dashboard, importing to content-typeFile
that is created by the core plugin "Upload"), but it does not work. It creates the register, but it does not upload the file.
For us, right now, the most important thing should be importing media from the view directly instead to do it from content, later, we could just connect them in the admin.
But your idea is pretty good.
@Alex01d Thanks I'll have a look
For us, right now, the most important thing should be importing media from the view directly
@SalahAdDin you mean an import interface like the one developped by Strapi?
For us, right now, the most important thing should be importing media from the view directly
@SalahAdDin you mean an import interface like the one developed by Strapi?
No no, the import/export button to be also in the Media view.
I published version 1.11.0
, the doc is up-to-date on how to import media. It's now possible to specify a file name, caption and alternative text when importing by url
@SalahAdDin in what would it be better than using the Strapi interface?
Well, we updated the plugin and we still don't see the import/export button directly in the Media view:
@SalahAdDin this page is about an issue different from the one you mention. Please, open a new issue for your use case
@Alex01d based on your comment in my PR, version 1.11.1
is out. Default value for caption and alternative text is an empty string
@SalahAdDin this page is about an issue different from the one you mention. Please, open a new issue for your use case
Actually, it is the last point on the issues' requesting list, that's why I pointed it here.
@SalahAdDin in what would it be better than using the Strapi interface?
@SalahAdDin in what would it be better than using the Strapi interface?
Sorry, I don't understand your question.
Also, it's only possible to import media if it is related to other content. I wish I could import media directly to upload or file content-type.
It would be great to have the import/export button on the Media Content screen, you know when you can update all media and later you can fix the relations by yourself in the case you want.
@SalahAdDin Strapi developed a media library interface where you can upload several media at once (see the screenshot above you posted). Why do you need to have an export/import button on this interface?
@SalahAdDin Strapi developed a media library interface where you can upload several media at once (see the screenshot above you posted). Why do you need to have an export/import button on this interface?
First of all, thank you again, you are a rock star for all the attention and patience you are having with us.
@Baboo7 I don't need to have the import button on that interface, but I need the ability to import it programmatically. Is there a way to programmatically import media not related to other content-types, specially setting the ID?
like:
await service.importData(
dataRaw: [{
"id": 31896,
"url": "http://www.anteprojectos.com.pt/wp-content/uploads/2010/03/35850a.jpg",
"name": "blablabla.jpg"
}],
options: {
slug: 'media', // <---- THIS?
format: 'json'
}
);
First of all, thank you again, you are a rock star for all the attention and patience you are having with us.
Thanks for the feedback π I'm doing my best to address fast all the relevant issues
Version 1.13.0
is published. What's new:
id
can be set! πawait service.importData(
[
{
"id": 31896,
"url": "http://www.anteprojectos.com.pt/wp-content/uploads/2010/03/35850a.jpg",
"name": "blablabla.jpg"
}
],
options: {
slug: 'media',
format: 'jso', // <-- javascript object, not 'json'
}
);
See full documentation in the services section and the importing data section of the doc.
@SalahAdDin I digged into the strapi upload plugin and they don't provide injection zones on the media library page. This means I can't display an import/export button as done on the content type pages.
First of all, thank you again, you are a rock star for all the attention and patience you are having with us.
Thanks for the feedback π I'm doing my best to address fast all the relevant raised issues
New version out
Version
1.13.0
is published. What's new:* media `id` can be set! π * media can be imported programmatically:
await service.importData( [ { "id": 31896, "url": "http://www.anteprojectos.com.pt/wp-content/uploads/2010/03/35850a.jpg", "name": "blablabla.jpg" } ], options: { slug: 'media', format: 'jso', // <-- javascript object, not 'json' } );
See full documentation in the services section and the importing data section of the doc.
@SalahAdDin I dug into the strapi upload plugin and they don't provide injection zones on the media library page. This means I can't display an import/export button as done on the content type pages.
Ok, no problem, we could suggest this on the forum.
I am closing this issue as every feature requested here was created. Thanks again @Baboo7!
@SalahAdDin You can try
Is your feature request related to a problem? Please describe. I need to import my multimedia files from an old system to strapi. Today it's possible to import it, but you can't mantain the ID reference, neither the caption, name or alternative text.
Describe the solution you'd like Today if I import the following
media
object:upload
orfile
content-type.Describe alternatives you've considered I tried to import the files directly to the
File
content-type (via dashboard, importing to content-typeFile
that is created by the core plugin "Upload"), but it does not work. It creates the register, but it does not upload the file.