Getting SL to recognize Swift Object as Image... SoftLayer_Virtual_Guest_Block_Device_Template_Group/createFromExternalSource.json - swift

SoftLayer support sent me to stackoverflow because they could not figure this out.
I have uploaded a VHD file to Swift object storage to import it as an Image. Because the image is larger than 2GB, I have uploaded all 2GB chunks and have created the appropriate manifest object in Swift to let me download the joined chunks. After uploading to Swift I can download the manifest URL and the MD5 for the uploaded file and the downloaded file match and I can boot the disk image locally. I do not have a Swift problem.
However, I can not get the SL portal or the API to consistently recognize my Swfit manifest object URI as a valid image. It works sometimes, but not others. I have tried making the Content-Type on the manifest object 'application/binary','application/octet-stream', and 'application/iso-9660-image' without success.
Typically I get a 500 error back from the:
SoftLayer_Virtual_Guest_Block_Device_Template_Group/createFromExternalSource.json
call with the error body: {"error":"The supplied file must be a image.","code":"SoftLayer_Exception_Public"}
Can anyone tell me definitively what the Content-Type should be (BTW curl uploads the chunks as 'application/x-www-form-urlencoded' and the manifest file as 'application/octet-stream') to make both the SL portal and the API work consistently?

Related

Can I upload already-encoded content to azure media services, instead of uploading a video and then encoding it? How?

I want to encode locally and upload to avoid spending money in encoding.
Is this allowed? I did not find any documentation on it.
When I simply uploaded a file to the storage, the media services account said it could not play it without the ISM file. I had to encode (was it re-encode? it was an mp4) the file I had uploaded - I want to avoid that.
Yes, absolutely allowed and encouraged for customers. Especially ones that have custom encoding requirements that we may not support.
You can upload an .ism file that you create along with your encoded files. It's a simple SMIL 2.0 format XML file that points to the source files used.
It's a bit hard to find searching the docs, but there is a section outlining the workflow here - https://learn.microsoft.com/en-us/azure/media-services/latest/encode-dynamic-packaging-concept#on-demand-streaming-workflow
There is also a .NET Sample showing how to do it here:
https://github.com/Azure-Samples/media-services-v3-dotnet/tree/main/Streaming/StreamExistingMp4
You can see the code line at 111 that shows how to generate the .ism file -
// Generate the Server manifest for streaming .ism file.
// This file is a simple SMIL 2.0 file format schema that includes references to the uploaded MP4 files in the XML.
var manifestsList = await AssetUtils.CreateServerManifestsAsync(client, config.ResourceGroup, config.AccountName, inputAsset, locator);

Azure storage Rest Api File service

I am trying to upload with Http request a file (not a blob) in Azure File service.
I have successfully uploaded a blob with Http request. I am using the same Authentication method (SharedKey). Inside documentation I found that I had to first create and then write a file.
The Create File operation creates a new file or replaces a file. Note
that calling Create File only initializes the file. To add content to
a file, call the Put Range operation
Is it correct. Does anyone knows any other option. It seems a bit wrong to me. Does anyone has an example in .net?
(I even tried this workflow but i got a 400 error)
I guess you were expecting the Create File API works like Put Block Blob which uploads the content in the request body. Actually Create File is similar to Put Page/Append Blob. It requires you to initialize the resource first and then update the content. You can refer to the sample that #Michael pointed in the comment.

How to display the images in offline using ionic

I have a gallery module, the functionality implemented in this module as below
- getting the file path from the server using ajaxrequest
- the response will be json object of all image file path
- setting the filepath in image src attribute
As we are using ajax request, the images are loading in online mode only.
so how to implement the functionality so that images should show in offline also.
You may consider returning images as base64 string from the server and store them in a localstorage.
On the view use data-ng-src directive like this .
In your controller check if there is no connection and set base64 string from the localstorage as this: $scope.data.image_url=
After loading an image once, your best bet is going to be get a base64 representation of it, and then persisting that to disk.
Get the base64 representation of the image here:
Get image data in JavaScript?
Write the base64 data to disk using ng-cordova/ionic native and the writeFile method using the Cordova file plugin.
http://ngcordova.com/docs/plugins/file/
writeFile(path, file, data, replace)
There are some great answers here that I would like to build on...
I would suggest using PouchDB as a cache for base64 and/or Blob data after you have downloaded the original (one of my apps does the same thing with mp3 data converted to a Blob). You could then implement a method that checks the cache for the image before making a network request.
Nolan Lawson has created an excellent library for these binary conversions: https://github.com/nolanlawson/blob-util
Just save the base64 string to your PouchDB instance after the initial download, you can then check for that data before your app reaches out to the network.
Just beware of storage limits on iOS Safari (~50mb default)...

With filepicker.io, is there a way to get the original file path?

I am using filepicker.io and specially computer as main service.
I would like to get the original file path of a file uploaded through the API.
For example, if I upload a file located at /my/path/in/my/computer/file.zip, I will get in the FPFile object the filepicker.io URL but not the original file path.
Is there a way to get it ?
PS: I have tried to retrieve the stat of the file too without success.
Due to browser security limitations, the real local path of the file is never exposed to the javascript application. For more information, see http://davidwalsh.name/fakepath

Downloaded ppt file seems to be corrupted

Recently I've integrated Google Drive with my iOS application. Everything works fine but .ppt files. Normally if a file is a Drive file I use downloadURL to download it. If the file belongs to Google Docs I use one of the exportLinks (exactly the same as Alain described it here).
However all .ppt files (with "mimeType": "application/vnd.google-apps.presentation") which come from Google Docs are corrupted after being downloaded (I use an export link with exportFormat=pptx). The same file downloaded via web browser works fine.
I use ASIHTTPRequest lib for downloading files (which also can be the reason of corrupted .ppt?).
Any ideas why only ppt files cause problems?
I can already tell you that the lib you're using isn't the cause:I'm not using it but I've the same problem: it seems that there the code received isn't 200 (if ($httpRequest->getResponseHttpCode() == 200)) as it shows me a specific error message I've asked to return in case of. Also, when I'm trying to download a presentation in PDF or txt, it shows the same error.
It's not really an answer but I'm trying to understand also why only presentations are causing problems.
EDIT: the code received is 302. If it can help...
EDIT 2: After trying, I noticed that the first parameter is the file id and the second the export format:
https://docs.google.com/feeds/download/presentations/Export?docId=filedid&exportFormat=pptx
But in the 302 code, I have this location:
https://docs.google.com/feeds/download/presentations/Export?exportFormat=pptx&id=fileid
Not only the two parameters aren't in the same order but the name is id and not docid
When I take this URL, put it as the export link and then try to copy the file, it's working. I get a 200 response and the inside of the file.
I hope it helps.