Hi Christian, For the "asdf" extension, you can simply register it with the MetadataService. For example:
myApplication.getMetadataService().addExtension("asdf", MediaType.valueOf("yourNew/mimeType")); For your second case, I'm not sure. As a workaround, you could register the "bin" extension with MediaType#APPLICATION_OCTET_STREAM. I would suggest entering a new RFE if you really need to upload something without extension. Maybe we could guess the extension in this case based on the posted entity's media type of fallback on a default "bin" extension. Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com -----Message d'origine----- De : Christian Haintz [mailto:christian.hai...@gmail.com] Envoyé : dimanche 8 mars 2009 12:47 À : discuss@restlet.tigris.org Objet : Re: Upload to Directory Hello Thierry, I played around with that but i didn't find a solution that fits my needs. I just want to be able to upload _any_ type of file to the Directory Object. Eg.: myPDF.pdf myTXT.txt myOwnFormat.asdf myFileWithoutExtension I succeed with the first two, but what about the last two. There is no MimeType for that registered and so is no MediaType. Is there a way to achieve this i am not able to see, or is it just not supported. Thank you. Best regards, Christian Haintz On Mar 7, 2009, at 8:53 AM, Thierry Boileau wrote: > Hello Christian, > > there is a mechanism based on the MetadaService [1] that checks the > media type of the uploaded file with the one deduced from the URI of > the resource. > For instance, you put a file with mediatype */* on a URI such as > http://www.example.com/fille.txt. > Based on the metadata service, the media type of the resource is > "text/plain". > > The rule is : if */* is not included into "text/plain" then, reject > the uploaded representation. it avoid to send a binary file when a > text file is expected. > > Having said that, this mechanism could be optional, it isn't. > > best regards, > Thierry Boileau > >> Hi, >> >> I simply wanna upload a File to the org.restlet.Directory. But all I >> get is: >> >> See Other (303) - The metadata are not consistent with the URI >> >> I don't know what that means, or what I can do against it. >> >> On the Server Side i do: >> Application application = new Application() { >> >> @Override >> public Restlet createRoot() { >> >> Directory dir = new Directory(getContext(), >> ROOT_URI); >> dir.setModifiable(true); >> dir.setDeeplyAccessible(true); >> >> return dir; >> >> } >> }; >> return application; >> >> And the client which is uploading a file looks: >> >> Client client = new Client(Protocol.HTTP); Representation rep = new >> FileRepresentation(fileOpt.getValue(), >> MediaType.ALL); >> Response response = client.put(reference, rep); >> >> Any suggestions? >> >> Thx, >> christian >> >> -- >> Christian Haintz >> Student of Software Development and Business Management Graz, >> University of Technology >> >> ------------------------------------------------------ >> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageI >> d=1279726 >> >> > > ------------------------------------------------------ > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId > =1281460 -- Christian Haintz Student of Software Development and Business Management Graz, University of Technology ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=12885 92 ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1317161