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

[BUG] Media (image) set to null after import, even if field is not in imported file #18

Closed
NicolasBrondin opened this issue Jul 8, 2022 · 10 comments
Assignees

Comments

@NicolasBrondin
Copy link

Describe the bug
Everytime we update content by importing data using CSV or JSON, any media field on the root of the schema is set to null, even if the said files doesn't contain the field column

The problem happens even if we let the column with exactly what was exported in the first place (full object or id)

To Reproduce

  1. Create schema with media field in it
  2. Add some content with media such as an image
  3. Export data
  4. Import exported data after removing media column

Expected behavior
Media data is unchanged

@middlebaws
Copy link

Also its important noticed, when you have more then one level in component. Import are missing populate for media types, I suppose is same problem of new API required specify populate level

@Baboo7
Copy link
Owner

Baboo7 commented Jul 12, 2022

I'm actively working on importing media

@Baboo7
Copy link
Owner

Baboo7 commented Jul 14, 2022

I published version 1.6.4 that supports media upload. Check the Config section of the doc for proper setup.
I did a few tests and it seems to work properly but I'm waiting for your feedback

@Baboo7
Copy link
Owner

Baboo7 commented Jul 16, 2022

Version 1.6.5 available. Check out the Importing Data section of the doc.

@middlebaws
Copy link

So, Service now should be setup in ./src/extensions?
Like this example in doc: https://docs.strapi.io/developer-docs/latest/development/plugins-extension.html#extending-a-plugin-s-content-types

Or need to be setup inside of serve.js from api?
Like this doc: https://docs.strapi.io/developer-docs/latest/development/backend-customization/services.html#adding-a-new-service

In my case I have this sceneario (really similar to what Nicolas describe),

  {
    id: 8,
    title: null,
    Banner: [ [Object] ],
  },

In my case, this Object inside Banner lose everything during import/export process. 😞

@Baboo7
Copy link
Owner

Baboo7 commented Jul 27, 2022

There is no service to setup (did I misunderstand something?). Version 1.6.5 should fix the issue about importing/exporting media.

About the objects exported as [ [Object] ], I'll dig into that. How deeply nested is the data having the issue?

@middlebaws
Copy link

middlebaws commented Jul 28, 2022

About Setup, sorry maybe I misunderstand documantation. I understand need to configure service now to have better compatibility when export. But thanks to clear, now its fine.

About how deep I'm using, let me try example here.
I just erase URL for s3 bucket (security), but you can sure its working.

{
    id: 8,
    title: null,
    Banner:  [{
            "id": 1,
            "title": "Test 1",
            "subtitle": "Subtitle 1",
            "buttonText": "Get started",
            "buttonHref": "/example",
            "styledType": null,
            "image": {
                "data": {
                    "id": 300,
                    "attributes": {
                        "name": "Frame 341 (1).png",
                        "alternativeText": "",
                        "caption": "Frame 341 (1).png",
                        "width": 524,
                        "height": 417,
                        "formats": {
                            "small": {
                                "ext": ".png",
                                "url": "S3bucket.url.here/image1",
                                "hash": "small_Frame_341_1_fcf6c37756",
                                "mime": "image/png",
                                "name": "small_Frame 341 (1).png",
                                "path": null,
                                "size": 282.21,
                                "width": 500,
                                "height": 398
                            },
                            "thumbnail": {
                                "ext": ".png",
                                "url": "S3bucket.url.here/image2",
                                "hash": "thumbnail_Frame_341_1_fcf6c37756",
                                "mime": "image/png",
                                "name": "thumbnail_Frame 341 (1).png",
                                "path": null,
                                "size": 58.82,
                                "width": 196,
                                "height": 156
                            }
                        },
                        "hash": "Frame_341_1_fcf6c37756",
                        "ext": ".png",
                        "mime": "image/png",
                        "size": 59.67,
                        "url": "S3bucket.url.here/image3",
                        "previewUrl": null,
                        "provider": "aws-s3",
                        "provider_metadata": null,
                        "createdAt": "2022-07-15T21:11:47.325Z",
                        "updatedAt": "2022-07-15T21:11:55.599Z"
                    }
                }
            },
            "icons": {
                "data": null
            },
            "background": {
                "data": {
                    "id": 84,
                    "attributes": {
                        "name": "Background_Banner_1.png",
                        "alternativeText": "Background_Banner_1.png",
                        "caption": "Background_Banner_1.png",
                        "width": 1440,
                        "height": 736,
                        "formats": {
                            "large": {
                                "ext": ".png",
                                "url": "S3bucket.url.here/background1",
                                "hash": "large_Background_Banner_1_c2731fcfda",
                                "mime": "image/png",
                                "name": "large_Background_Banner_1.png",
                                "path": null,
                                "size": 657.12,
                                "width": 1000,
                                "height": 511
                            },
                            "small": {
                                "ext": ".png",
                                "url": "S3bucket.url.here/background2",
                                "hash": "small_Background_Banner_1_c2731fcfda",
                                "mime": "image/png",
                                "name": "small_Background_Banner_1.png",
                                "path": null,
                                "size": 174.57,
                                "width": 500,
                                "height": 256
                            },
                            "medium": {
                                "ext": ".png",
                                "url": "S3bucket.url.here/background3",
                                "hash": "medium_Background_Banner_1_c2731fcfda",
                                "mime": "image/png",
                                "name": "medium_Background_Banner_1.png",
                                "path": null,
                                "size": 377.97,
                                "width": 750,
                                "height": 383
                            },
                            "thumbnail": {
                                "ext": ".png",
                                "url": "S3bucket.url.here/background4",
                                "hash": "thumbnail_Background_Banner_1_c2731fcfda",
                                "mime": "image/png",
                                "name": "thumbnail_Background_Banner_1.png",
                                "path": null,
                                "size": 47.06,
                                "width": 245,
                                "height": 125
                            }
                        },
                        "hash": "Background_Banner_1_c2731fcfda",
                        "ext": ".png",
                        "mime": "image/png",
                        "size": 836.74,
                        "url": "hS3bucket.url.here/background4",
                        "previewUrl": null,
                        "provider": "aws-s3",
                        "provider_metadata": null,
                        "createdAt": "2022-05-09T18:52:55.167Z",
                        "updatedAt": "2022-05-09T18:52:55.167Z"
                    }
                }
            }
        }],
},

@Baboo7
Copy link
Owner

Baboo7 commented Jul 31, 2022

Version 1.7.0 is out and export has been rewritten. It should work as expected now

@middlebaws
Copy link

middlebaws commented Aug 1, 2022

Working pretty good now!
Just get problem when you import for different language, seems need to apply same concept to deeply components.

I mean, when import in:

  • English (default) > 100% working
  • Spanish (second language) > 50% Simple components work, but if have something more deep like:
  {
    id: 8,
    title: null,
    Banner: [ [Object] ],
  },

Not work =/

Forget to mention, I tested in 1.7.1 version.

@Baboo7
Copy link
Owner

Baboo7 commented Aug 7, 2022

Version 1.10.0 is out. Deepness can now be set in the export modal

image

@Baboo7 Baboo7 closed this as completed Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants