Importer: How to upload category logo images


(Jay Pfaffman) #1

I’m adding group support to the Ning importer (right now Ning groups are ignored; a trivial change to import the groups results in group posts going into uncategorized).

It does this:

  • Ning groups become Discourse groups and categories
  • Ning group members go into Discourse groups (admins imported as owners)
  • Ning Wall posts become a topic in the Category
  • Ning discussions for the group are put in the proper Discourse category
  • Read-only permission for everyone for the categories
  • reply-create permission for group members in the categories

But that’s not important now.

Ning also has a icon for each group. I want that group to be the Category Logo Image. I don’t see uploaded_logo_id in any of the importers and a cursory look around the controllers hasn’t helped either.

Can someone point me to where I might be able to

  • upload the group icon
  • get the uploaded_logo_id for the uploaded icon

Thanks.


(Régis Hanol) #2

You need to create an Upload with your image and then use its id as the uploaded_logo_id.


(Vinoth Kannan) #3

These lines may help you. Here src is an external URL. It is downloading image from URL and creating new Upload model record. From this you can get upload.id to use in uploaded_logo_id.