I used dropzone as CSV/XLS file uploader. I use this option to filter and restrict CSV/XLS file:
acceptedFiles: "text/csv,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
Now I just see XLS file in windows dialog box and doesn't see CSV file. Off course when I change filter drop-down to all files, I see CSV file and select it. But I wanna to method or option to solve this issue.
Do you have any solution for see both XLS/CSV files together?
Dropzone.js simply puts the values from the AcceptedFiles attribute directly into the html component.
<input accept="text/csv,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
It looks like text/csv is not an accepted value even though it is a valid mime type. .csv is recommended.
See here HTML Input="file" Accept Attribute File Type (CSV).
Related
Here is my problem: i have a rich text lite field, used to store a contact photo. Parameter of this field is:
- only allow for thumbnail with an image attachment name (mandatory) = ContactPhoto
Parameter of the Rich Text Lite
When the user clicks on it, a standard import dialog box (managed automatically by Notes) is open and all images type can be selected as shown here :
ScreenShot of the import dialog box
With the following code, I'm able to check the size of the photo:
Set uidoc=ws.CurrentDocument
Call uidoc.Refresh(True,True)
Set doc=uidoc.Document
oneKB = 1024
PhotoTrouve = False
Forall i In doc.Items
If i.type = Attachment Then
Set emb = doc.GetAttachment(i.values(0))
If emb.source="ContactPhoto" Then
PhotoTrouve = True
If emb.filesize > (50 * oneKB) Then
strError="The size of the photo should be less than 50 Kb."
End If
End If
End If
End Forall
If PhotoTrouve= False Then
strError="Photo is mandatory."
End If
But this is not enough. I also need to check if this is well a .jpg file. The problem is that, as this is a thumbnail, its name is ContactPhoto, without any extension and i don't know how to get the original extension of the file selected by the user (seems not to be possible).
So my question is : is it possible to force the standard dialog box of the "thumbnail rich text lite" field in order that it proposes only .jpg extension file type to the user ? How to ?
Or if not, do you know a solution to check that the original file is well a .jpg file ?
Note : even if I name the attachment CPhoto.jpg (instead of ContactPhoto) by example, the user can select all type of images, not only a jpg. The photo is saved in $FILE of the document under the name of CPhoto.jpg but I don't think that the file is finally a real .jpg format. And I absolutely need a jpg image as my final objective is then to export that image in an xml file, with the good format of jpg.
Thanks a lot for your replies and help.
Karen
You will have to translate it from C#, but code to check the file contents to see if it is a jpg can be found in this answer to a previous question on this site.
Is it possible to add additional file types to be recognised as images and thus trigger automatic creation of an image view when a resource is uploaded?
SVG files will preview in CKAN, but we have to manually add the image view e.g.
https://datastore.landcareresearch.co.nz/dataset/novel-yeasts-from-new-zealand-forests/resource/3812ee6b-dd45-45c9-b425-6a18375e5727
With text (for example) we can specify file format extensions to recognise as text and automatically create a text preview (ckan.preview.text_formats...). Is there an equivalent for images?
Thanks
It would only be possible by modifying the source code for your instance:
https://github.com/ckan/ckan/blob/master/ckanext/imageview/plugin.py#L9
Seems like a great idea to have the image view on a par with the text view in this regard, so I made a pull request:
https://github.com/ckan/ckan/pull/3380
Is there any chance I can open or save an existing file after clicking a link from an xpage?
My scenario: A link to an attachment ( an excel file ) so all users when clicking the link, they will have the possibility to open or save the file.
My app works both on Lotus Client and web.
Thanks for your time
I assume (from your comments) that you are looking for a way to store one certain Excel file somewhere and to give users access to this file with a link.
You can achieve that this way:
Store your Excel file in your database at Resources / Files (e.g. as "sample.xls")
Create a link in your XPage pointing to this file just with the name (e.g. "sample.xls")
<xp:link escape="true" value="sample.xls">Excel sample file</xp:link>
Users can open or download this file in browser or XPiNC clicking on link.
You need to set proper content type. For an existing file you would need to make your own service (XAgent) to alter it. Or you can try to set it for the link.
And bear in mind, that action associated to content type is configured in browser - so every user has it's own.
If you just want to make the file available normally, Knut's answer is about what you want: store the file as a File Resource in the database and link to it on the XPage. I would add one adjustment, though: start the URL in the "value" property with a "/", e.g.
<xp:link value="/sample.xls" text="Excel sample file"/>
The reason for this is to ensure that the generated link is always relative to the NSF, not the XPage - without it, you'd have a problem if you open the XPage with a link like "/someView/someDocKey" (with display-XPage-instead in the form) or if you happen to include extra path info after the XPage (e.g. "/foo.nsf/somePage.xsp/some/path/info").
But if you mean that you want to cause the browser to display the Save File dialog instead of whatever its normal behavior would be (e.g. IE opening the Excel file in the window), the core of the solution is the Content-Disposition header. If this header is set to tell the browser the file is an "attachment", then the browser will prompt the user (or do whatever its normal file-download routine is) instead of opening inline.
Depending on how the file is stored, the solution will either be fairly easy or not-impossible-but-sort-of-a-pain:
If it's a file attached to a document, I believe that the normal control generates links to an attachment-download service that adds this header normally.
If it's not (e.g. it's a file resource), then Frantisek's advice comes into play: you'd have to write your own shim XAgent or servlet that writes this header and then spits out the file's contents.
While the latter is doable, it's a pain, and so I'd suggest trying to wrangle your attachment into a normal document if at all possible. For example, if it's attached to a document in a hidden view, you could do something like:
<xp:panel>
<xp:this.data>
<xp:dominoDocument var="attachmentDoc" action="openDocument" ignoreRequestParams="true">
<xp:this.documentId><![CDATA[${javascript:
database.getView("SomeLookupView").getFirstEntry().getUniversalID()
}]]></xp:this.documentId>
</xp:dominoDocument>
</xp:this.data>
<xp:fileDownload value="#{attachmentDoc.Body}"/>
</xp:panel>
I'm trying to build a chrome extension that overrides a download of a file and displays it in the browser. For example if you click on a link to a '.csv' file I'd like it to render in the browser instead of downloading it.
Chrome already does it for PDF's types and the Xml Tree extension also does exactly that for xml files.
So it should be possible, just not sure how to go about catching that event?
An implementation along the lines indicated by in the previous answers and specifically designed for CSV files can be found in this extension of mine on github:
https://github.com/rgrp/chrome-csv-viewer
Furthermore, with the new(ish) chrome webrequest API a direct approach is also now possible along the following lines:
Listen to onBeforeRequest (this has to be in a background script - see background.js)
Check if this is a CSV file (mimetype or file extension)
If so cancel the request and then display the data using xhr
A working version of this can be found in a branch of that extension: https://github.com/rgrp/chrome-csv-viewer/tree/4-webrequest-intercept
You could always look at the XML Tree code :).
If you only need to work with links, and not opening files from the address bar or File > Open, you could build a content script that adds a click event listener to every link.
In the event listener function:
Add e.preventDefault() in the first line to prevent the browser 'following' the link.
Using the link href value, get the data with XMLHttpRequest.
In the XMLHttpRequest callback, open a new tab and render content accordingly.
Obviously, in many ways, this is not a great solution:
you want 'normal' links to be handled as usual by the browser
how can you tell if a text file contains comma-separated values (for example) except by looking at the file extension which, of course, may not be reliable?
Are you specifically thinking of .csv files -- and/or other specific types of content?
We have a SharePoint Document library, where we store html files with links to external files. Samples:
mypicture.jpg.html
mywordfile.docx.html
mypdffile.pdf.html
and so on. Now by default all Files show up with the HTML Icon, referenced in the DOCICON.XML file. Thats of course correct as the .html extension shows, it is a HTML file. But we want the files to have different icons, based on their original file type.
Is there a way to automatically change the Icon
during rendering or
when we save the file to the library (via SharePoint API)?
Any other approachs?
Why not use a little jquery to change the icon during rendering? Each doc in your library should be contained in
<td class="ms-vb-icon"><a tabindex=...><img ... src="/_layouts/images/ichtm.gif"></a></td>
I think you can slurp that into an array, assign a new var that's just the href stripped of path/filename. and .html, and use that to replace htm in the src tag.
Could you not just edit the DOCICON.xml to add the ".jpg.html" and ".docx.html" extensions in?
For a full listing of icon files see all "ic*.gif" files in the TEMPLATE\IMAGES directory under the 12 hive. Unfortunately, this will not solve your problem, but this is where you can change it based on the extension, if you so choose.
Note that a blog I wrote a while back has a different focus, but does discuss where the icons come from: http://wiki.threewill.com/display/is/2007/10/14/External+Link+for+Editing+a+SharePoint+Document.