When I am trying to upload multiple images using Umbraco Drag and Drop functioanlity, I am getting No property type exists with alias umbracoFile. I have custom media type Top Banner with alias name banner. When I upload the image, it is using the custom media type as contentTypeAlias. The custom media type doesn't have a property named umbracoFile. So, I need to change this behavior. I need to use default File/Image media type for uploading the image. How I can achieve it?
I have created a new Media Type 'Top Banner'(Alias:Banner) and properties on Banner media type
Title(TextString)
Banner Image(Image Cropper)
Image(FIleUpload)
Link(Content Picker)
Subtitle((TextString))
VideoLink (TextString)
Centered(checkbox)
Logo(FIleupload)
Is Black Layout for Link Text(checkbox)
If I am adding a property umbracoFile(Property Type : FileUpload) into Banner Media type, the files are getting uploaded and no error is coming.
Exception Details:
No property type exists with alias umbracoFile.
Stack Trace:
at Umbraco.Core.IO.MediaFileSystem.GetProperty(IContentBase content, String propertyTypeAlias)
at Umbraco.Core.IO.MediaFileSystem.SetUploadFile(IContentBase content, String propertyTypeAlias, String filename, Stream filestream)
at Umbraco.Core.Models.ContentExtensions.SetValue(IContentBase content, String propertyTypeAlias, String filename, Stream filestream)
at Umbraco.Web.Editors.MediaController.<PostAddFile>d__26.MoveNext()
These are the Media types
Ok, so. What's happening is that Umbraco tries to determine what the media type is in a couple of ways - first, on the Client side in JavaScript it checks to see what Media Types are allowed in the particular folder you're adding files to.
If you have a recent version of Umbraco (since around November last year), it should be giving you the option to choose which Media Type to upload the files to if you've got more than one allowed type for the folder you're uploading to, otherwise it will silently choose Image or File depending on the extension of the file you're uploading.
The error you're getting may indicate that you're choosing the custom Banner media type while uploading the files, but it may not be set up with the mandatory fields for it to work.
What are your property Aliases? You've only listed the names and the types. My guess is you haven't got the Image Cropper set up with an alias of umbracoFile, and you should also set up the other media aliases as labels similar to the Image media type.
As per Robert's comment I have updated the \Umbraco\lib\ng-file-upload\ng-file-upload.min.js file(line number 185 for unminified file).
if (h == "Banner") {// my custom media type alias is Banner
var regexp = /(?:\.([^.]+))?$/;
var ext = regexp.exec(a.file.name)[1];
ext = ext.toLowerCase();
var imageExtensions = ["png", "jpeg", "gif","jpg"];
if (imageExtensions.indexOf(ext)>-1) {
h = "Image";
}
var fileExtensions = ["pdf", "doc", "gif", "xls", "xlsx", "odt", "ods", "ppt", "pptx", "txt", "zip", "svg", "csv"];
if (fileExtensions.indexOf(ext) > -1) {
h = "File";
}
console.log(ext);
}
Related
I've been searching for a couple of days on how to get the album art for a song (or a frame capture of a video) from a file path. All I could find is things related to Mediastore like this answer where it requires getting the album ID of the file.
Cursor cursor = getContentResolver().query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI,
new String[] {MediaStore.Audio.Albums._ID, MediaStore.Audio.Albums.ALBUM_ART},
MediaStore.Audio.Albums._ID+ "=?",
new String[] {String.valueOf(albumId)},
null);
if (cursor.moveToFirst()) {
String path = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Albums.ALBUM_ART));
// do whatever you need to do
}
But I can't find a guid on how it works, how can pass the file to Mediastore or how can I get the album ID of the media or anything... Currently I get the media information using MediaMetadataRetriever but I can't find a way to get the album art or a video thumbnail of a media file using it...
** Update :-
If Mediastore must be used to get the media files in the first place before using it to get their data, I can implement it instead of what I'm currently doing (Currently I iterate the device files to get the supported files) and it can be a better option as Mediastore supports getting data from external storages as well.
Any help is appreciated.
If using MediaMetadataRetriever , you can have a try with follow sample code :
private void loadingCover(string mediaUri)
{
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
mediaMetadataRetriever.SetDataSource(mediaUri);
byte[] picture = mediaMetadataRetriever.GetEmbeddedPicture();
Android.Graphics.Bitmap bitmap = BitmapFactory.DecodeByteArray(picture, 0, picture.Length);
musicCover.SetImageBitmap(bitmap);
}
In addition , not forgatting to add permission :
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Invoke it as follow :
File file = new File("/storage/sdcard/Movies/music1.mp4");
if (file.Exists())
{
loadingCover(file.AbsolutePath);
}
I really hope you will be able to help me out on this one.
I am new to pdf.js so for the moment, I am playing around with the pre-built version to see if I can integrate this into my web app.
My problem:
I am using tcpdf to generate a pdf file which I would like to visualize using pdf.js without having to save it to a file on the server.
I have a php file (generate_document.php) that I use to generate the pdf. The file ends with the following:
$pdf->Output('test.pdf', 'I');
according to the tcpdf documentation, the second parameter can be used to generate the following formats:
I: send the file inline to the browser (default). The plug-in is used if available. The name given by name is used when one selects the "Save as" option on the link generating the PDF.
D: send to the browser and force a file download with the name given by name.
F: save to a local server file with the name given by name.
S: return the document as a string (name is ignored).
FI: equivalent to F + I option
FD: equivalent to F + D option
E: return the document as base64 mime multi-part email attachment (RFC 2045)
Then, I would like to view the pdf using pdf.js without creating a file on the server (= not using 'F' as a second parameter and passing the file name to pdf.js).
So, I thought I could simply create an iframe and call the pdf.js viewer pointing to the php file:
<iframe width="100%" height="100%" src="/pdf.js_folder/web/viewer.html?file=get_document.php"></iframe>
However, this is not working at all....do you have any idea what I am overlooking? Or is this option not available in pdf.js?
I have done some research and I have seen some posts here on converting a base64 stream to a typed array but I do not see how this would be a solution to this problem.
Many thanks for your help!!!
EDIT
#async, thanks for your anwer.
I got it figured out in the meantime, so I thought I'd share my solution with you guys.
1) In my get_document.php, I changed the output statement to convert it directly to base64 using
$pdf_output = base64_encode($pdf->Output('test_file.pdf', 'S'));
2) In viewer.js, I use an XHR to call the get_document.php and put the return in a variable (pdf_from_XHR)
3) Next, I convert what came in from the XHR request using the solution that was already mentioned in a few other posts (e.g. Pdf.js and viewer.js. Pass a stream or blob to the viewer)
pdf_converted = convertDataURIToBinary(pdf_from_XHR)
function convertDataURIToBinary(dataURI) {
var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
var base64 = dataURI.substring(base64Index);
var raw = window.atob(base64);
var rawLength = raw.length;
var array = new Uint8Array(new ArrayBuffer(rawLength));
for (i = 0; i < rawLength; i++) {
array[i] = raw.charCodeAt(i);
}
return array;
}
et voilà ;-)
Now i can inject what is coming from that function into the getDocument statement:
PDFJS.getDocument(pdf_converted).then(function (pdf) {
pdfDocument = pdf;
var url = URL.createObjectURL(blob);
PDFView.load(pdfDocument, 1.5)
})
except for:
widget.setVideoTitle(title);
widget.setVideoDescription(description);
widget.setVideoKeywords(keyword1, keyword2, ..., keywordn);
widget.setVideoPrivacy(privacy);
is there also a possibility to set Category and Tags along the vid upload???
cheerz!
from the widget I think not, only the properties that you mentioned and in onApiReady:
https://developers.google.com/youtube/youtube_upload_widget#onApiReady
This event fires when the internal command API, which enables you to set metadata for a newly uploaded video, is ready. The event handler for this event can call the following functions to set metadata for an uploaded video:
widget.setVideoTitle(title) – The title parameter is a string that specifies the video title.
widget.setVideoDescription(description); – The description parameter is a string that specifies the video description.
widget.setVideoKeywords(keyword1, keyword2, ..., keywordn); – The function takes a list of string parameters, each of which specifies a keyword for the video.
widget.setVideoPrivacy(privacy) – The privacy parameter is a string that specifies the initial privacy setting for the newly uploaded video. Valid values are public, unlisted, and private. The default setting is public.
Using Umbraco 5.1 API,
I am able to create a new content type (for creating content nodes under content tab) using the below code.
// create content type
var typeBuilder = context.Hive.Cms().NewContentType("testType", "Test Type")
.Define("value", "contentPicker", "Content")
.Commit();
// create content node
var packageNode = context.Hive.Cms().NewRevision(packageNodeName, packageNodeName, "testType");
packageNode.SetUploadedFile("value", postedFile);
packageNode.Publish();
packageNode.Commit();
But is there a way to create media node using fluent API? I need to create a new custom media node with a custom type in the media tab tree.
I have tried the below approaches, but none of them seem to work
1) context.Hive.Cms().NewRevision();
2) context.Hive.Cms<IMediaStore>().NewRevision();
3) builderStep.NewRevision<Media, IMediaStore>();
4) builderStep.NewRevision<TypedEntity, IMediaStore>();
This works, but the resulting media type is not complete, as it throws an error "name should be specified" when I try to manually create a media using this type.
CmsBuilderStep<IMediaStore> builderStep = new CmsBuilderStep<IMediaStore>(context.Hive);
var typeBuilder = builderStep.NewMediaType<EntitySchema, IMediaStore>("testType")
.Define("package", "uploader", "General Properties")
.Commit();
Finally I decided to create the media type manually, and use the below code to create media item via code
// Creating a new Media item using the scorm package zip file.
var packageNode = context.Hive.Cms<IContentStore>().NewRevision(packageNodeName, packageNodeName, "testType")
.SetUploadedFile("package", postedFile)
// set parent to media root folder - this is what makes it come under media tree
.SetParent(FixedHiveIds.MediaVirtualRoot)
.Publish()
.Commit();
I have a web service that requires special headers to be sent in the request. I am able to retrieve expected responseXMLs using an XMLHttpRequest and setRequestHeader().
Now I would like to create a new tab (or window) containing the response document. I would like the default XMLPrettyPrint.xsl file applied to it and when the source is viewed, I'd like to see the un-styled source as when viewing a normal .xml file.
Any ideas?
I ended up creating a protocol handler.
The biggest trick that I didn't find to be documented well was the fact that the XPCOM contract ID must start with "#mozilla.org/network/protocol;1?name=". E.g.,:
/* as in foo:// . This is called the scheme. */
var thisIsWhatMyProtocolStartsWith = "foo";
var contractID = "#mozilla.org/network/protocol;1?name=" + thisIsWhatMyProtocolStartsWith;