Importing Media in the Vanilla Forums Import Script


(Abdul Munim Zahid) #1

I have been trying to implement media import in the Vanilla forums. But after many tries i’m still stuck.

In the text (csv) file from the Vanilla Porter, we get a table called "Media"
which has the following values stored:

MediaID:int,
Name:varchar(255),
Type:varchar(128),
Size:int,
ImageWidth:int,
ImageHeight:int,
StorageMethod:varchar(24),
Path:varchar(255),
InsertUserID:int,
DateInserted:datetime,
ForeignID:int,
ForeignTable:varchar(24)

Now in my tries,
I defined a new method “def import_media” and i also made sure that it was being executed.

However, i have tried every possible way and the media import is just not working.
Heres an example of the data in the media table:

“118",
“SAM_0350.JPG",
“image/jpeg",
“3438485",
\N,
\N,
“local",
“FileUpload/scratch/fr.jpg",
“296",
"2011-03-21 17:40:49”,
\N,
\N

So basically the only thing i cant get right is the code to go in this part:

def import_media
  puts "", "importing media files..."
  
  
  
end

I have tried varieties of different commands to no luck :confused:
If anyones is feeling up to the challenge or want to contribute please do help me.
@zogstrip Also said that he would be happy to merge any pull request.

I can provide him the dump file too.

Edit:
In the Media Table there are two columns called:

ForeignID:int,
ForeignTable:varchar(24)

Now, if the the image is 186th post:
Its ForeignID will be 186.
and its Foreign Table will be: comment

Or if the image is in the 87th topic.
Its ForeignID will be 87.
and its Foreign Table will be: discussion

Must note that in vanilla we have “discussion” which is called “topic” in discourse.
and a “comment” of vanilla is called “post” in discourse.

I made a script to add the images via a simple “/imgsource…blablbal tag>” in the body of their respective topic or post, but discourse still wont show the images.


(Kane York) #2

Are you getting the actual image files in the right place?


(Abdul Munim Zahid) #3

yep!
pretty sure i am!