In my database, i have a field to save url of mp3 file! I'm trying using media type of form field but it only support for images!
Please help me!
If you are saving a URL, then there is no need to use a media type, you only need a simple text box. If you want the form to allow a user to actually upload an MP3 then you can use a file type input box.
Related
I'm using ldap3.
I can connect and read all attributes without any issue, but I don't know how to display the photo of the attribute thumbnailPhoto.
If I print(conn.entries[0].thumbnailPhoto) I get a bunch of binary values like b'\xff\xd8\xff\xe0\x00\x10JFIF.....'.
I have to display it on a bottle web page. So I have to put this value in a jpeg or png file.
How can I do that?
The easiest way is to save the raw byte value in a file and open it with a picture editor. The photo is probably a jpeg, but it can be in any format.
Have a look at my answer at Display thumbnailPhoto from Active Directory in PHP. It's especially for PHP but the concept is the same for Python.
basically it's about either using the base64 encoded raw-data as data-stream or actually using a temporary file that is serverd (or used to determine the mime-type)
I have a submit only XPage based form that has an inputRichText field for storing screenshots and a multi file upload (using the XPages Multiple File Uploader from OpenNTF) for uploading one or more attachments. When submitted I need both the screenshots and the attachments to appear in a single rich text field which will be accessed via the Notes Client only (non XPages).
Currently the form stores the attachments and screenshots in separate fields. I have tried appending one field to the other on save (using SSJS in the submit button, however because the Screenshots are stored as MIME and the attachments as NotesRichText, it is not letting me do it.
Is there some way (preferably in SSJS) that I can convert either the MIME to RichText or vice versa so that I can append one field to the other? I have tried searching for various solutions to no avail, as well as trying different file upload controls from OpenNTF.
Ideally I need something like this to work:
var rtItemAttachments:NotesRichTextItem = docTo_Backend.getFirstItem("attachments"); //This is the field I want everything in
var rtItemFiles:NotesRichTextItem = docTo_Backend.getFirstItem("uploadedFiles");
rtItemAttachments.appendRTItem(rtItemFiles); //Fails on this line
docTo_Backend.removeItem("uploadedFiles");
Speak after me: there is no RichText in the web, all there is is MIME.
You can set the RT field to store its content in MIME (a property). This makes things much easier.
To stitch things together you need to stick with MIME. These are roughly the steps
Get the text and images as MIME
Get your attachments as stream (the embeddedObjects has a method for that)
Convert the stream to BASE64 and create a new mime-part with it. (Looking at an attachment eMail source someone sent through the internet should give you a pretty good idea how it looks like)
You end up with:
MimeHeader
MimePart for Text (HTML)
MimePart for Screenshots (if they are not inline images in html)
MimeParts for attachments
The special effect: if you add to the HTML with links to the attachments, it looks nicer.
Of course the BIG question: WHY?
You could simply design a Notes form that has two fields, no need to fold it into one. Hope that helps.
A good piece of code to look at to understand the MIME stuff is the OpenNTF eMail bean
I'm working on Struts2 framework. I need to upload an excel file to the buffer so that I can extract its informations and print them into a table in a jsp page. I followed this tutorial : http://www.roseindia.net/struts/struts2/struts-2-file-upload.shtml , and so I could upload any type of file. My question is then : how can restrict the type into .xls and .xlsx ? and how can I get the content of the rows existing in the excel file? I read somewhere that i can use the Apache POI API ... but I couldn't get much how to do. Thank you.
Have you seen the Struts 2 File Upload Tutorial ?
It shows how to restrict to certain mime types.
You need the mime types described here for excel.
There is an opensource library called jxl. After you haveuploaded your file to your server you can read it in and iterate through ght rows. Its very easy to do.
How do I create audiofield (formfield as audio widget) content programmatically?
Specifically how I do "import" file contents (in this case MP3 files).
I tried node import module but does not seem to work properly.
This is Drupal 6 implementation.
Thanks,
Murali
I am not sure I fully understand your question. If you would like to upload an mp3 file to a cck node, you can use the filefield module.
create a new cck node-type
add a filefield to this nodetype, and select 'file' as the field type.
Configure this filefield: Under "Permitted upload file extensions", enter "mp3".
Under "number of values", selected "unlimited" if you would like to upload an arbitrary number of mp3 files.
Once you define your node-type, you can programatically create a node with node_save(). See here: http://drupal.org/node/1111514
I have a table with documents saved some of them in pdf, some of them image.
I want to create a web app, to show the images (that can be either pdf, either jpg) in the same control.
I can manage to see pdf, if I set the Response.ContentType = "application/pdf" or image if I set "application/jpg". But the problem is that how can I get the file type, having only the stream saved into the database? Does it have the stream the file type information in it?
Thanks.
No, a stream does not have a content type associated with it. If you had the original filename, you could attempt to derive the content type from that, but it wouldn't be foolproof.
Many file formats have a series of "magic bytes" that allow you to detect what (might) be in the file. PDF, for example, begins with the bytes "%PDF" (note: I'm not an expert on PDF, and there may be situations where that is not true).
If you have no other option, you could attempt to parse the file using various libraries until you found one that worked (System.Drawing.Image.FromStream(), iTextSharp, etc).