Manually Uploading/Inserting Documents to the Repository
I have seen a number of requests by individuals to know how to manually upload a
document and have it inserted in the repository. The following tutorial will
show you how to manually upload a file to a repository. The following
procedures have been tested using DNN 4.4.1 and Repository 3.01.10.
NOTE: As with each of my other postings regarding database manipulations
to a DotNetNuke installation this should not be treated as a primary method for
uploading documents to your DNN site, however, it can be used to help when
uploading large files by allowing you to FTP the files up which will result is
better transfer rates than via the web interface for larger files. I am NOT
responsible for any damage to your DNN installation that might occur because of
you using these scripts, however I can tell you that they do work on 4.4.1 as I
have been testing and using these scripts on my own portal.
Setup
Prior to uploading your file to your portal you will need to rename your file,
adding some additional text to the file name. This must be added after a
period. For example I will be showing you how to upload a file called
"Unemp.jpg" I have renamed the physical file to "Unemp.auto.jpg" you must
format your new file name in this manner. This appears to be a method of
abstraction used by the repository module to ensure unique file names.
Loading the File
This portion of the process is very simple, you must upload your renamed file to
the "Repository" directory in the current portal's folder. Typically you will
want to use an FTP client for this transfer, but it can be done via the File
Manager. (NOTE: if you are planning on using the file manager, you might as
well use the regular upload process from within the repository>)
The next step is to insert the needed data record to list the uploaded file in
the Repository. However before you are able to insert this record you must know
a few pieces of information.
Gathering Required Information
First you will need to note the "ModuleId" for the Repository you wish to insert
the record for. To obtain this information while logged into your site with
administrative permissions, select "About.." from the Module Actions Drop Down
list. You will be taken to a page that tells you about the repository, in your
URL you should notice a portion with "/mid/xxx/" where xxx is a number, this is
your module id. Please note this number as you will need it later.
The second piece of information that you will need is the userid of the user
that will be listed as the uploader. You can find this id by going to "Admin"
-> "User Accounts" and locating the user. When you select edit for the
respective user you will see "ID: X" where X is the users id. Please note this
number as you will be using it in the scripts below.
Now that you have the needed information it is time to actually create the
record within the repository for the document. Please ensure that you replace
my example information with your correct information.
Insert DB Record
The final step is to insert the needed database information for the file you
just uploaded. Below is the insert script needed to add this database record.
Be sure to substitute all of the appropriate values for your specific DNN
installation and upload file.
/*
NOTES:
ModuleId = Specific Repository Module you are working with
CreatedByUser = ID for the user adding the document, from the users table
UpdatedByUser = ID for the user adding the document, from the users table
Author = The display name for the user adding the document
FileSize = The size of the file, text field, 39 K for example
FileName = The name of the file as you uploaded it
*/
INSERT INTO grmRepositoryObjects(ModuleId, CreatedByUser, CreatedDate, UpdatedByUser,
UpdatedDate, [Name], Author, AuthorEmail, FileSize, [FileName],
Approved, ShowEMail, Summary, [Description], [Downloads], clicks,
RatingVotes, RatingAverage)
VALUES(372, 1, GETDATE(), 1, GETDATE(), 'Manual Upload Test', 'Mitch Sellers',
'mitchel.sellers@gmail.com', '39 K', 'Unemp.auto.jpg', 1, -1, 'This is the summary',
'Demonstration file description', 0, 0, 0, 0.0)
Now that you have this record inserted into your databse you should be able to navigate to your "Repository" module and see the newly uploaded file. You will be able to fully edit and delete the file without any difficulties. Please post any comments, concerns or questions below. For technical assistance please visit my blog!
Posted by Mitchel on Tuesday, March 06, 2007
Currently, there are no comments. Be the first to post one!
Click here to post a comment