V2.0 Save Photos to FileSystem

rated by 0 users
This post has 19 Replies | 7 Followers

Not Ranked
Posts 38
Points 200
MartinBlue Posted: Fri, Nov 25 2005 9:43 PM

I'm having an issue trying to save gallery files to the file system. I have tried just changing the "enableFileSystemStorage" attribute to true in the gallery key, but it still saves the photos to the database. If I change the "enableFileSystemStorage" attribute to true in the AttachmentSettings and CacheSettings entries, the files won't upload properly. If I upload an image with those settings set, it seems like it uploads the file, but then it displays a broken image for the picture. Is this a known bug, or am I missing a setting somewhere? Other users seem to be having the same issue.

Thanks,

Martin

<Gallery enableFileSystemStorage="true" fileSystemStorageLocation="~/photos/storage" cacheStorageLocation="~/photos/cache" allowEncodedUnicodeCharsInMetadata="true">

<AttachmentSettings enableFileSystemStorage="true" fileSystemStorageLocation="~/photos/storage"  enableDataStoreStorage="false" enableDirectLinks="false" extentensions = "gif,jpg,jpeg,png" />

<CacheSettings enableFileSystemStorage="true" fileSystemStorageLocation="~/photos/cache" enableDataStoreStorage="false" enableDirectLinks="false" extentensions = "gif,jpg,jpeg,png" />
</Gallery>

My first CS site: www.monkey.ca
  • | Post Points: 20
Top 100 Contributor
Posts 208
Points 3,015
Chiwi replied on Sat, Nov 26 2005 3:48 AM

It could be permissions...If you are running XP make sure the ASPNET user has write access to the blogs and photos gallery, or if you have 2K then ensure you have these settings for the NETWORKSERVICE account.

Hope this helps.

If not what error is logged in the reports section?

CS Gallery Manager @ SourceForge.net
  • | Post Points: 20
Not Ranked
Posts 18
Points 300
SleepyDeux replied on Sat, Nov 26 2005 10:23 AM

I'm experiencing the same problem with 2.0.51107.1266.  The error logged when trying to display one of the file-based images is:

User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR
Path: /CS/photos/viewPicture.aspx?App=january_2005&PostID=7 as HTTP GET
Referrer: /CS/photos/january_2005/default.aspx
Message: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at CommunityServer.Galleries.Components.GalleryUrls.PictureUrl(GalleryPost galleryPost)
at CommunityServer.Galleries.Controls.PictureDetails.DataBind()
at System.Web.UI.Control.DataBind()
at System.Web.UI.Control.DataBind()
at System.Web.UI.Control.DataBind()
at System.Web.UI.Control.DataBind()
at System.Web.UI.Control.DataBind()
at System.Web.UI.Control.DataBind()
at System.Web.UI.Control.DataBind()
at System.Web.UI.Control.DataBind()
at System.Web.UI.Control.DataBind()
at System.Web.UI.Control.DataBind()
at CommunityServer.Controls.TemplatedWebControl.DataBind()
at CommunityServer.Galleries.Controls.LayoutTemplate.DataBind()
at CommunityServer.Galleries.Controls.LayoutTemplate.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.AddedControl(Control control, Int32 index)
at System.Web.UI.ControlCollection.Add(Control child)
at CommunityServer.Galleries.Controls.GalleryThemedControl.CreateChildControls()
at System.Web.UI.Control.EnsureChildControls()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain()

The photos are present in the storage folder, but they do not render properly.  Also, images added prior to setting enableDataStoreStorage = "false" are still displayed as expected.

  • | Post Points: 20
Not Ranked
Posts 38
Points 200
MartinBlue replied on Sat, Nov 26 2005 10:55 AM
Where did you find the error log?
My first CS site: www.monkey.ca
  • | Post Points: 20
Not Ranked
Posts 18
Points 300

http://ServerName/CS/ControlPanel/Tools/Reports/ExceptionsReport.aspx

or you can reach it by

    Settings | System | Reports

 

 

  • | Post Points: 20
Not Ranked
Posts 31
Points 410
I've been having a heck of a time getting the galleries to work in filesystem mode, too.  It looks like there's one bug in cs_PostAttachment_ToggleTemporary where a '0x' should be 0x.  There seems to be another bug that causes the PostID to remain zero in the cs_PostAttachments table.  Even if I correct those two things, however, all I get is a small and large thumbnail.  If I click the thumbnails I get a similar error to the one above, even though I can see that the photo is in the correct storage folder on disk.

Have any of these filesystem bugs been confirmed by Telligent yet? 

My config settings are:
 enableFileSystemStorage="true"
 enableDataStoreStorage="false"

My error:
[NullReferenceException: Object reference not set to an instance of an object.]
CommunityServer.Galleries.Controls.PictureDetails.BindData() +229
CommunityServer.Galleries.Controls.PictureDetails.AttachChildControls() +585
CommunityServer.Galleries.Controls.GalleryThemedControl.CreateChildControls() +170
System.Web.UI.Control.EnsureChildControls() +100
CommunityServer.Controls.TemplatedWebControl.DataBind() +12
CommunityServer.Galleries.Controls.PictureDetails.DataBind() +45
System.Web.UI.Control.DataBind() +86
System.Web.UI.Control.DataBind() +86
CommunityServer.Controls.TemplatedWebControl.DataBind() +19
System.Web.UI.Control.DataBind() +86

  • | Post Points: 20
Top 25 Contributor
Male
Posts 2,208
Points 30,885
CS Developers
alowe replied on Wed, Nov 30 2005 9:50 AM
I've logged the issue so someone will look at it.
  • | Post Points: 20
Top 100 Contributor
Posts 195
Points 2,890
iso3200 replied on Fri, Dec 16 2005 4:25 AM

bump...

I had a problem with a ballooning database since all my uploaded images since V2.0B1 were being stored both in the database and on the filesystem.  Even setting <Gallery><AttachmentSettings enableDataStoreStorage = "false" /> didn't work as I got the same error as jason_looney above.

Here's a script I wrote that clears the Content columns of my cs_PostAttachments since these are already on my filesystem - i.e. i only want them stored once.  Hopefully someone will find this useful and can modify it to their needs.  Note that this may delete content that is stored only in the database. 

set nocount on
--Find rows with Content columns that need to be cleared since they're already on the filesystem
select PostID, DataLength(Content)'ContentLength'
into #temp
from cs_PostAttachments
where DataLength(Content) > 0
order by PostID desc

--required variables
declare @ptrval binary(16)
declare @PostID int
declare @ContentLength int

--loop through temptable to find PostIDs and ContentLengths
declare mycursor cursor fast_forward for
 select PostID, ContentLength from #temp

open mycursor
fetch next from mycursor into @PostID, @ContentLength
while @@fetch_status = 0
begin
 select @ptrval = TEXTPTR(Content)
 from cs_PostAttachments
 where PostID = @PostID
 UPDATETEXT cs_PostAttachments.Content @ptrval 0 @ContentLength
 fetch next from mycursor into @PostID, @ContentLength 
end
close mycursor
deallocate mycursor

drop table #temp

--now shrink the db and allow 10% free space in MDF file
DBCC SHRINKDATABASE (CommunityServer, 10)

  • | Post Points: 20
Top 75 Contributor
Posts 253
Points 1,700
MrVJTod replied on Fri, Dec 16 2005 9:03 AM

This could also delete photos that are only stored in the database.

I have about 200 that I need to move out of the database and into the filesystem.

Looking at the DB, there are a few distinguishing factors

   Only Stored in the Database : FriendlyFileName IS NULL, Height=0, Width=0

   CS2B1 : Stored in Both Locations : NOT FriendlyFileName IS NULL, Height>0, Width>0

1) Always make a backup before you get your hands dirty.

2) Check Step1.

  • | Post Points: 35
Top 100 Contributor
Posts 195
Points 2,890
iso3200 replied on Fri, Dec 16 2005 11:03 AM
MrVJTod wrote:

This could also delete photos that are only stored in the database.

I have about 200 that I need to move out of the database and into the filesystem.

right.  sorry.  i'll edit my post to be more specific to my situation.  i want ALL my photos on my filesystem. 

  • | Post Points: 5
Top 25 Contributor
Posts 1,160
Points 70,210
CS Developers

Ok here goes...  Photos only on the filesystem was broken in CS 2 b1  and would result in missing records in the cs_PostAttachements table...  (all the posts were going in as PostID 0)...

In B2 it looks like the PostID0 record is still being created (but is harmless for all practical purposes)...  This has been logged as a bug...

Additionally the correct record is written to the cs_PostAttachements table... each post saved in the filesystem only configuration, will overwrite the PostID 0 record, and add a new record with the correct postid in B2...

The ContentSize, Height and Width all must be greater than zero.  The only difference between photos saved with enableDataStoreStorage true vs false is the Content field...  which in the latter case is set to 0x

To remove files from the database, just view them with enableFileSystemStorage set to true, the system will automatically make the correct files...  once you have them on your web server, you should just set the Content col to 0x (binary) and set enableDataStoreStorage to false on the AttachementSettings block

No changes other than the physical location are supported on the CacheSettings at this time.

  • | Post Points: 65
Top 75 Contributor
Posts 253
Points 1,700
MrVJTod replied on Mon, Dec 19 2005 9:53 AM

Dan, thanks.  This does provide some good insight.

I can see the file created in Storage when it gets viewed.  That makes things easy for me.  I can join the cs_PostAttachments with cs_Sections to create urls to view my DB-Only pictures.

I see with B2, there is a new file naming scheme as well and that file names are updated when they are first viewed.  1000.3.3836 becomes 1000.3.3836.OriginalFileName.

Looking through my DB, only posts made with B1 and B2 have a height and width > 0.  All of my old photos have Height=0 and Width=0.  All my photos do have ContentSize>0.

  • Most of my pictures are from nGallery.  For all of these, height=0 and width=0.
  • With CS1 & CS1.1, I never used the website interface to upload pictures.  I used the FTP add-on.  For all of these, height=0 and width=0.
  • With B1 & B2, I'm now using Chiwi's tool.  For all of these, height>0 and width>0.
  • | Post Points: 5
Not Ranked
Posts 8
Points 115
DanBartels wrote:

To remove files from the database, just view them with enableFileSystemStorage set to true, the system will automatically make the correct files...  once you have them on your web server, you should just set the Content col to 0x (binary) and set enableDataStoreStorage to false on the AttachementSettings block

Just so I'm sure that I understand, if both enableFileSystemStorage and enableDataStoreStorage have both always been set to true, then will all the files already be in place on the file system? If so, then as I see it all that needs to be done are the changes outlined above to the Content column and the enableFileSystemStorage setting and the photos will be stored only on the file system. Is this correct?

Thanks in advance for your help,

Alun

  • | Post Points: 20
Top 25 Contributor
Posts 1,160
Points 70,210
CS Developers

Yes, that is correct...  That is sort of the thinking behind the current defaults; is when you have a preference, you can make the change and all your existing photos should continue to work... 

Of course, I am going to suggest you have a backup of the database and \storage location before changing anything (this is beta software after all)....

Dan

  • | Post Points: 5
Top 500 Contributor
Posts 51
Points 495
bayloafer replied on Fri, Jan 20 2006 12:19 PM
DanBartels wrote:

Ok here goes...  Photos only on the filesystem was broken in CS 2 b1  and would result in missing records in the cs_PostAttachements table...  (all the posts were going in as PostID 0)...

In B2 it looks like the PostID0 record is still being created (but is harmless for all practical purposes)...  This has been logged as a bug...

Additionally the correct record is written to the cs_PostAttachements table... each post saved in the filesystem only configuration, will overwrite the PostID 0 record, and add a new record with the correct postid in B2...

The ContentSize, Height and Width all must be greater than zero.  The only difference between photos saved with enableDataStoreStorage true vs false is the Content field...  which in the latter case is set to 0x

To remove files from the database, just view them with enableFileSystemStorage set to true, the system will automatically make the correct files...  once you have them on your web server, you should just set the Content col to 0x (binary) and set enableDataStoreStorage to false on the AttachementSettings block

No changes other than the physical location are supported on the CacheSettings at this time.

Okay a complete newbie here. When you say set the Content col to 0x (binary). How and where is that accomplished? Thanks
  • | Post Points: 20
Page 1 of 2 (20 items) 1 2 Next > | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com