umbracoBytes returns the wrong value - umbraco7

I'm using umbracoHelper.Media() to get a media object, and then GetPropertyValue("umbracoBytes") to get the file size.
However, the file size that is stored in the backoffice and returned is incorrect.
Should I go directly to the filesystem to get the correct value, i.e. is this a bug?
I've seen a lot of posts about umbracoBytes and I'm sure it is a problem that hasn't already been resolved.
Thanks
Muiris

Related

How get stream of selected image by user (BitmapFactory.DecodeStream(inputStream) returns null)

When loading the selected image of the user and passing the stream to BitmapFactory.DecodeStream(inputStream) I always get as result null.
I load the stream of the image like this:
Stream stream = new Java.Net.URL(Uri.Parse($"file://{imageFile.Path}").ToString()).OpenStream(); I also tried many other variants like:
BitmapFactory.DecodeStream(Activity.ContentResolver.OpenInputStream(uri) or new Java.IO.FileInputStream(imageFile.Path)
I have permissions for WriteExternalStorage. Whats causing the problem? How to fix it?
The sample project is available here https://github.com/mfe-/App10
You probably need to use the content resolver. Unfortunately, the process is not consistent across sdk versions and even sometimes devices. Take a look at how the media picker plugin handles getting the file. I've actually ended up copy/pasting its GetFileForUriAsync method into my project.
https://github.com/jamesmontemagno/MediaPlugin/blob/master/src/Media.Plugin/Android/MediaPickerActivity.cs

Laravel: display file from cloud storage in the browser

This snippet from the Laravel docs, https://laravel.com/docs/5.5/responses#file-responses, seems to be just what I need:
return response()->file($pathToFile);
The problem is that my file is stored on an S3 disk, and I can't seem to reference it properly.
I tried using Storage::disk('s3')->getDriver()->getAdapter()->applyPathPrefix($myPath); to get the fully qualified file name. It just returned the value of $myPath though.
I then tried to get the url using Storage::disk('s3')->url($myPath); The URL looks fine however Symphony says it does not exist. When I check with Storage::disk('s3')->exists($myPath); however, it returns true.
How do I go about displaying a file from cloud storage directly in the user's browser?
EDIT:
More details below:
To save the item in the first instance I am using $map->storeAs('/my/path/maps/filename.pdf', ['disk' => 's3']);
The output of url() is "https://s3.ap-southeast-2.amazonaws.com/my.domain.com/my/path/maps/filename.pdf"
When I cut-and-past the url in a browser address bar, it loads no problem
It seems to me that the response()->file() method does not accept a URL parameter. Is that the case?
Question - does the file need to be publicly available? (It currently is, but I would prefer to make it private).
The following should be enough:
$path = Storage::disk('s3')->url($filename);
I don't have a working example set up, but from memory $filename should be the same as what you originally placed in the ->put() method. So when you say $mypath in your question, hopefully that isn't already prefixing stuff like your s3 instance.
If this isn't the case, can you edit the question to include the result of ->url() and an example of your put() call and $path.
Looking at the edit, I think I understand what you are trying to do, which has been solved here:
https://laracasts.com/discuss/channels/laravel/file-response-from-s3

How to Get FHIR Photo for Patient from a URL

Consider the FHIR Patient data at http://spark.furore.com/fhir/Patient/f201.
How can I get the photo object referenced therein at URL "binary/#f006"??
I would have thought an HTTP GET on http://spark.furore.com/fhir/binary/#f006 would have done it, but alas...
the data there is wrong. Your conversion to the get was correct, but you ended up with a wrong URL because the reference is wrong in the first place.
It should say: url="Binary/f006" which would equate to a get of http://spark.furore.com/fhir/Binary/f006. That doesn't work either, which is another error in the way things are defined.
See http://gforge.hl7.org/gf/project/fhir/tracker/?action=TrackerItemEdit&tracker_item_id=6107 for follow ups
Yes, this reference is outdated, and we are not distributing Binaries currently as part of the examples in the FHIR specification. Our server Spark loads the examples from the specification when we initialize the database, hence the images are not there.
For now, I have uploaded the correct image to Binary/f006 and have updated the link in Patient/f201, so things should work now. When we re-initialize the database (we don't do this often), these changes will be reversed, but a simple PUT to Binary/f006 and an update of Patient/f201 will fix this of course.

CSV insert to database

This is not working as we discussed previously, for some reason and I have done is create some $vars for the uploaded file.
Code available here (Pastebin).
But never actually inserts anything
When doing a var_dump($csv_row) i get: bool(false)
var_dump($fh) shows: resource(89) of type (stream)
var_dump($insert_str) shows all 1700 records from the csv file (obviously too big to post on here)
So I’m guessing the while statement or the whole from if statement is wrong somewhere. Really really would appreciate some help on this, I need to get it working by tomorrow (monday)
You seem to be using the codeigniter database library wrong. I can see a
$this->db->set($insert_str);
but no $this->db->insert() to be found. The set() method only useful with an update() or insert() following it, See the docs, search for $this->db->set().
You either want to use the $this->db->insert_batch() (on the same doc page, unfortunately no direct links for sections) form and build up an array of arrays with your records (so you won't have to create a long sql string either).
Or you can use the $this->db->query() and just feed the $insert_str to it where you now call $this->db->set().
According to your question:
var_dump($insert_str) shows all 1700 records from the csv file
So i would rule out the possibility of the while loop or the if not working.
Put this code at the top of the controller or before reading csv file
ini_set('auto_detect_line_endings', true);
Check if this will work for you

Using DiskVolumeInfo (Cluster Failover API)

I found the DiskVolumeInfo property -- I'd like to use it to get some disk information in a clustered setup.
http://msdn.microsoft.com/en-us/library/windows/desktop/bb309235(v=vs.85).aspx
The problem is I have no idea what technology is required to get this data. This doesn't resemble the standard C/C++/C#/VB format of function/method reference.
Question: How do I get the DiskVolumeInfo data?
Ideally I could write the binary output directly to a file, say data.bin.
Any ideas would be helpful, thanks.
The process for getting object properties is described here.
Looks like you need to call the ClusterResourceControl function with a handle to the physical disk resource and the CLUSCTL_RESOURCE_GET_PRIVATE_PROPERTIES control code. You can then use ResUtilFindBinaryProperty to extract the DiskVolumeInfo property from the property list returned.
For anyone still interested:
As given here CLUSCTL_RESOURCE_STORAGE_GET_DISK_INFO_EX is a better way to do this.

Resources