22 September 2006
HowTo: Move a File to another FileGallery
I'm going to start posting a lot of my old Duncan Nuggets (as Dave Burke likes to call them) here for others to start reading.  This is the first of a lot to come.

How to move a file from one FileGallery to another 
NOTE: This script was written for Community Server 2.1 RTM. 

This method uses a stored procedure to move a single file (aka Post) to another File Gallery (aka Section).  Attached is an SQL script file named move_file_to_filegallery.zip that when executed, will create a stored procedure named _move_file_to_filegallery in your database. 

After the sproc is created, you can execute it by running the following command:

EXEC _move_file_to_filegallery @PostID, @toSectionID, @ClearTags

You need two bits of information beforing executing:
  • @PostID - This is the PostID of the file you want to move. 
  • @toSectionID - This is the SectionID of the File Gallery you want to move the file to.
Following the examples above now that we have the two required integers, we can now execute the sproc to move the file.  The line would read:

EXEC _move_file_to_filegallery @PostID = 234, @toSectionID = 543125, @ClearTags = 1

NOTE: It is recommended to always clear the Tags, since they only exist in the previous FileGallery and not the new one.  So leave it @ClearTags = 1.
There is also error checking built in, so view the Messages for any errors that may have occurred.

Reader's Comments

Enterprise Search users.  You may want to modify the sproc and look for the line for Enterprise Search.  Uncomment this line, as it will clear the index for the file you are moving.

# 23 September 06 5:02 PM

news of the day a grab bag for what's happening in Community Server Sean Winstead provides a brief report

# 26 September 06 3:37 PM

Telligent's Eric Duncan blogs on how to move a file from one File Gallery to another.

# 22 November 06 11:15 AM

Telligent's Eric Duncan blogs on how to move a file from one File Gallery to another.

# 12 March 07 11:20 AM
Gary said:

Your attachment is corrupt!!!

# 16 November 07 11:45 AM

I really apologize for the corruption.

CommunityServer corrupts blog attachments when upgraded from CS 2.0 to CS 2.1.

If I had known at the time, I would have copied the file first.  But at last, I do not have a copy of that file anywhere.

I can write another if you like.

# 16 November 07 1:46 PM
Joshua said:

Eric,

If you can find the time, could you recreate the SPROC for this and post it/send it? I am very interested in this.

# 03 December 07 9:05 AM

Hey Joshua:

CS 2.0, 2.1, and 3.0 are vastly different for this approach.

Contact me via email eric-VIA-eduncan911.com, or the Contact me link in the header bar.

# 03 December 07 11:20 AM
CodePoet said:

Is there any way to move a file from one download folder to another?

# 12 November 08 10:42 AM

@CodePoet: I believe you were the one who emailed me this morning?  I replied to your email.  :)

This was suppose to do exactly that: move a file from one folder to another.  But CS 3.1 is completely different, and would require a different sql script.

# 12 November 08 11:05 AM
Leave a Comment
Comment Policy: HTML is not allowed. Links and line breaks are converted automatically.
(required) 
(optional)
(required) 

 


  
Enter the anti-spam code you see above (required)

 

Comment Notifications
Subscribe to this post's comments using RSS

If you would like to receive an email when updates are made to this post, please register here