[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EP-tech] Re: How to rename a file uploaded by a user automatically



Tim, thank's a lot for the hint.

The following now works for us, although it should be probably localized as described in http://wiki.eprints.org/w/Instructions_for_local_plugins

In perl_lib/EPrints/Plugin/Screen/EPrint/UploadMethod.pm we added 2 lines to the sub class "action_add_format".

	if( $filename =~ /^[A-Z]:/i )
	{
		$filename =~ s/^.*\\//;
	}
	else
	{
		$filename =~ s/^.*\///;
	}
	my $eprintid = $self->{processor}->{eprint}->get_value( "eprintid" ); 			#added
	$filename =~ s/.+?\.([^.]*$|$)/new_first_part_of_the_filename_$eprintid\.$1/; 	#added

Georgios, I hope it's also useful for you.

Best,
Volker

--
Volker Schallehn

Ludwig-Maximilians-Universit?t M?nchen
Universit?tsbibliothek
Referat Elektronisches Publizieren

Geschwister-Scholl-Platz 1, 80539 M?nchen, Germany



-----Original Message-----
From: eprints-tech-bounces at ecs.soton.ac.uk [mailto:eprints-tech-bounces at ecs.soton.ac.uk] On Behalf Of Tim Brody
Sent: Tuesday, December 11, 2012 4:43 PM
To: eprints-tech at ecs.soton.ac.uk
Subject: [EP-tech] Re: How to rename a file uploaded by a user automatically

On Thu, 2012-12-06 at 19:32 +0200, Dimitrakakis Georgios wrote:
> I am very interested in this as well!
> 
> So, if somebody has any idea please share...
> 
> Best,
> 
> G.
> 
> > Hi all,
> >
> > Does anyone know how to rename a file uploaded by a user   
> > automatically? And in addition the eprintid should be a part of the   
> > renamed filename. It's EPrints 3.3.10

Hi,

EPrints doesn't support this. If you wanted to modify the core you would
need to look in:
perl_lib/EPrints/Plugin/Screen/EPrint/UploadMethod.pm

And its sub-classes.

--
All the best,
Tim.