Made file upload use the Form API instead of the Storage API due to name hacks
This commit is contained in:
parent
6f441d69c3
commit
57fc140369
5 changed files with 15 additions and 12 deletions
|
|
@ -15,6 +15,7 @@
|
|||
- fix: Fixed the left column template, which still used the RawHeadTags
|
||||
macro. (perlDreamer Consulting, LLC)
|
||||
- Fixed a bad module name in the updated WeatherData asset (perlDreamer Consulting, LLC)
|
||||
- File and Image handling via Storage.pm (perlDreamer Consulting, LLC)
|
||||
|
||||
7.3.11
|
||||
- Added an option for enabling coverage tests to testCodebase.pl.
|
||||
|
|
|
|||
|
|
@ -245,13 +245,11 @@ sub processPropertiesFromFormPost {
|
|||
my $self = shift;
|
||||
$self->SUPER::processPropertiesFromFormPost;
|
||||
delete $self->{_storageLocation};
|
||||
my $storage = $self->getStorageLocation;
|
||||
|
||||
##The file form element adds a _file to each input name.
|
||||
##This thing should really try to use the whole Form API, but that's a major
|
||||
##change to this Asset
|
||||
my $filename = $storage->addFileFromFormPost("file_file",1);
|
||||
my $fileStorageId = WebGUI::Form::File->new($self->session,{name => 'file'})->getValueFromPost;
|
||||
my $storage = WebGUI::Storage->get($self->session, $fileStorageId);
|
||||
$storage->setPrivileges($self->get('ownerUserId'), $self->get('groupIdView'), $self->get('groupIdEdit'));
|
||||
my $filename = $storage->getFiles()->[0];
|
||||
if (defined $filename && $filename ne $self->get("filename")) {
|
||||
my %data;
|
||||
$data{filename} = $filename;
|
||||
|
|
|
|||
|
|
@ -136,10 +136,10 @@ sub edit {
|
|||
#-------------------------------------------------------------------
|
||||
sub editSave {
|
||||
my $self = shift;
|
||||
my $tempStorage = WebGUI::Storage->create($self->session);
|
||||
|
||||
##This is a hack. File uploads should go through the WebGUI::Form::File API
|
||||
$tempStorage->addFileFromFormPost("file_file");
|
||||
my $tempFileStorageId = WebGUI::Form::File->new($self->session,{name => 'file'})->getValueFromPost;
|
||||
my $tempStorage = WebGUI::Storage->get($self->session, $tempFileStorageId);
|
||||
|
||||
foreach my $filename (@{$tempStorage->getFiles}) {
|
||||
my $storage = WebGUI::Storage::Image->create($self->session);
|
||||
|
|
|
|||
|
|
@ -700,13 +700,18 @@ sub www_editListingSave {
|
|||
|
||||
##This is a hack. File upload should go throught the WebGUI::Form::File API
|
||||
##so that future changes don't affect us like this
|
||||
my $screenshot = $storage->addFileFromFormPost("screenshot_file");
|
||||
my $screenshotStorageId = WebGUI::Form::File->new($self->session,{name => 'screenshot'})->getValueFromPost;
|
||||
my $uploadedScreenshot = WebGUI::Storage->get($self->session, $screenshotStorageId);
|
||||
my $screenshot = $uploadedScreenshot->addFileFromFormPost("screenshot");
|
||||
|
||||
if (defined $screenshot) {
|
||||
$data{filename} = $screenshot;
|
||||
$storage->generateThumbnail($screenshot);
|
||||
$storage->addFileFromFilesystem($uploadedScreenshot->getPath($screenshot));
|
||||
}
|
||||
|
||||
$uploadedScreenshot->delete;
|
||||
|
||||
my $productName = $self->session->form->process("productName");
|
||||
|
||||
my $isNew = 0;
|
||||
|
|
|
|||
|
|
@ -260,11 +260,10 @@ sub www_editFontSave {
|
|||
return $session->privilege->adminOnly() unless ($session->user->isInGroup(3));
|
||||
|
||||
if ($session->form->process('fid') eq 'new') {
|
||||
my $storage = WebGUI::Storage->create($session, 'new');
|
||||
|
||||
##This is a hack. It should use the WebGUI::Form::File API to insulate
|
||||
##us from future form name changes.
|
||||
my $filename = $storage->addFileFromFormPost('fontFile_file');
|
||||
my $fileStorageId = WebGUI::Form::File->new($self->session,{name => 'fontFile'})->getValueFromPost;
|
||||
my $storage = WebGUI::Storage->get($self->session, $fileStorageId);
|
||||
my $filename = $storage->getFiles()->[0];
|
||||
|
||||
if ($filename) {
|
||||
my $font = WebGUI::Image::Font->new($session, 'new');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue