Forum OpenACS Q&A: How to upload MANY web pages to user's home

I have a user with 15Mb of web pages/images he wants to manage under
OpenACS 3.2.2.  Since there are hundreds of files, it was easiest to
FTP the files to the server and untar them in his users directory.

Now that they're there, they don't appear in his listing.  I assume
this is because the file system and database are not synced.  I tried
static-syncer-ns-set.tcl, but had no success from the user's
viewpoint.  How can I get these files visible for him to manage?

BTW - He'd have really liked the ZIP file upload feature in WimpyPoint
for use in his homepage area!

Collapse
Posted by Glen Stewart on
This is an awful hack, but it got the pages in there:
#!/usr/bin/ksh

if [ "$1" = "" ]
then
  echo ""
  echo "Please specify the root path of the files to be imported!"
  echo "eg. acsImport /pub/www/acs/www/users/45/"
  echo ""
  exit
fi

echo ""
echo "Working..."
echo ""

managed_p="f"
modifyable_p="t"
content_type="NULL"

cd "$1"
find . > $HOME/acsImport.paths

read ans?"Enter the highest file_id number used in the users_files table: "
file_id=$ans

read ans?"Enter the owner_id of the user who these files will belong to: "
owner_id=$ans

read ans?"Enter the file_id of the user's UserContent personalRoot folder: "
personalRoot=$ans

for theEntry in `cat $HOME/acsImport.paths`
do
  if [ "$theEntry" != "." ]
  then
    filename=`basename "$theEntry"`
    
    if [ -d "$theEntry" ]
    then
      directory_p="t"
      file_pretty_name="$filename"
      file_size="0"
    else
      directory_p="f"
      file_pretty_name="FileSystem uploadedFile"
      file_size=`ls -l "$theEntry" | sed 's/  */	/g' | cut -f5`
    fi
    
    ((file_id=file_id+1))
      
    depth=`echo "$theEntry" | sed 's/[^/]//g' | wc -c`
    # number of slashes in the path, plus 1
    
    if [ "$depth" -eq 2 ]
    then
      # this is the parent directory depth back to haunt us - use personalRoot instead of parent_id
      echo "INSERT INTO users_files (file_id, filename, directory_p, file_pretty_name, managed_p, modifyable_p, file_size, content_type, owner_id, parent_id) VALUES($file_id, '$filename', '$directory_p', '$file_pretty_name', '$managed_p', '$modifyable_p', $file_size, $content_type, $owner_id, $personalRoot);" >> $HOME/acsImport.sql
    else
      echo "INSERT INTO users_files (file_id, filename, directory_p, file_pretty_name, managed_p, modifyable_p, file_size, content_type, owner_id, parent_id) VALUES($file_id, '$filename', '$directory_p', '$file_pretty_name', '$managed_p', '$modifyable_p', $file_size, $content_type, $owner_id, $parent_id);" >> $HOME/acsImport.sql
    fi
    echo "SELECT users_file_id_seq.nextval;" >> $HOME/acsImport.sql
       
    if [ -d "$theEntry" ]
    then
      # we store the parent_id for use with files in this folder
      parent_id=$file_id
    fi
  fi
done

echo ""
echo "Done - use $HOME/acsImport.sql to import your file info AFTER reviewing it!"
  

# Example structure and data...

#INSERT INTO users_files (file_id, filename, directory_p, file_pretty_name, 
#managed_p, modifyable_p, file_size, content_type, owner_id, parent_id) 
#VALUES(234, 'ike03.gif', 'f', 'FileSystem uploadedFile', 'f', 't', 84370, 
#NULL, 31, 223);

#file_id 234
#filename ike03.gif
#directory_p f
#file_pretty_name FileSystem uploadedFile
#managed_p f
#modifyable_p t
#file_size 84370
#content_type NULL
#owner_id 31
#parent_id 223