box api direct link for music file - box-api

dropbox has /media api that provides a direct link to be used for audio steaming with html5 audio tag. I do not see similar thing with box.
the real problem is that I cant use "GET /files/{file id}/content" for music streaming because it requires BoxAuth in header.
How do I do it?

Direct download link is only available for paid box users not for the free user. So if you are free user then you have to upgrade your account to paid user and then after you will get the direct download link. See the box support answer here
Or else you can use the download api. See the documentation
This link is only valid for 15 minutes so after 15 minutes you have to again call the download api and you will get the fresh direct download link valid for next 15 minutes.

When you create a shared link for the file, a direct download link is also returned i.e. the download_url field in the following JSON:
{
"type":"file",
"id":"2192049121",
"sequence_id":"1",
"name":"brand_new_name.psd",
"description":"",
"size":1266400,
"path":"\/brand_new_name.psd",
"path_id":"\/0\/2192049121",
"created_at":"2012-06-04T21:32:20-07:00",
"modified_at":"2012-06-04T21:32:21-07:00",
"shared_link": {
"url": "https://www.box.com/s/0bb6907e48920c98d484",
"download_url": "https://dl.boxcloud.com/shared/static/0bb6907e48920c98d484.webdoc",
"password_enabled": false,
"unshared_at": null,
"download_count": 0,
"preview_count": 0,
"access": "Open",
"permissions": {
"download": true,
"preview": true
}
}
"etag":"72e96dad26aa67a5f7435548c86b7a8a331f0ae9",
"created_by":
{
"type":"user",
"id":"13344957",
"name":"Sean Rose",
"login":"sean+test#box.com"
},
"modified_by":
{
"type":"user",
"id":"13344957",
"name":"Sean Rose",
"login":"seanrose#stanford.edu"
},
"owned_by":
{
"type":"user",
"id":"13344957",
"name":"Sean Rose",
"login":"seanrose#stanford.edu"
},
"parent":
{
"type":"folder",
"id":"0",
"sequence_id":null,
"name":"All Files"
}
}

Related

Autodesk Forge Design Automation - Error Opening a model - How to bypass Dialog Box "Model has been transmitted from remote location"

I'm trying to use the Design Automation api to open a Revit model from our BIM360 account, eg. to upgrade it from a previous version of Revit
When I test locally, some rvt files display a dialog box during opening:
Transmitted File - this file has been transmitted from a remote location - see image attached (this is a side effect from being downloaded from BIM360)
dialog box on file open Transmitted file
my question is - how can I bypass this dialog box so that the addin can work with Design Aurtomation (in which no UI, dialogs or warnings are supported)
I did some research on Jeremy T's posts on this issue, and found some information, about how to use the DialogBoxShowing event to catch and respond to dialog boxes before they appear..
https://thebuildingcoder.typepad.com/blog/2009/06/autoconfirm-save-using-dialogboxshowing-event.html
However, the problem is that this event is part of the UIApplication namespace, so is likely not available in the Design Automation cloud Revit engine
https://www.revitapidocs.com/2017/cb46ea4c-2b80-0ec2-063f-dda6f662948a.htm
Also in any case it appears that this particular event is not fired when a model is opened
https://forums.autodesk.com/t5/revit-api-forum/dialogboxshowing-event-not-firing-when-model-is-opened/td-p/5578594
Any ideas about how I can open transmitted models for processing with Design Automation?
Thanks!
Ed G
The file from BIM 360 is a eTransmitted workshared files. To open such a file in DesignAutomation for Revit, you will need to use OpenOptions (DetachAndPreserveWorksets or DetachAndDiscardWorksets). If you preserve the worksets and would like to save the file, remember to use the correct SaveAsOptions.
Explicitly specify a local name to your input file in your activity:
{
"alias": "prod",
"activity": {
"id": "YourActivity",
"commandLine": [ "$(engine.path)\\\\revitcoreconsole.exe /al $(appbundles[YourBundle].path)" ],
"parameters": {
"rvtFile": {
"zip": false,
"ondemand": false,
"verb": "get",
"description": "Input Revit model",
"required": true,
"localName": "input.rvt",
}
},
"engine": "Autodesk.Revit+2020",
"appbundles": [ "YourName.YourBundle+label" ],
"description": "Bundle description."
}
}
In your app bundle open the file input file "input.rvt" using OpenOptions DetachAndPreserveWorksets or DetachAndDiscardWorksets.
ModelPath path = ModelPathUtils.ConvertUserVisiblePathToModelPath("input.rvt");
var opts = new OpenOptions
{
DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets
};
var document = application.OpenDocumentFile(path, opts);
This was covered in the my AU class (see video at 37 min mark).

Permanent shared url in box api

My requirement
One user uploads the file to box from my application using API and other users should be able to see that file as a link in my application.
Im not getting the shared url at the time of upload. And from the document, I understood that the shared url expires soon. Is it possible to get a permanent url to access file by other users (without login to box) ?
Shared links aren't automatically created when you upload a file. You need to make a request to the API to create one. You can find the documentation for how to do that here - https://developers.box.com/docs/#files-create-a-shared-link-for-a-file.
If you set the access field to open and leave the unshared_at time empty, then you'll get a link that anyone can access and that won't expire.
For example, your request might look like:
PUT https://api.box.com/2.0/files/FILE_ID
{ "shared_link": { "access": "open" } }
and then you'll get a response containing the created link:
{
...
"shared_link": {
"url": "https://www.box.com/s/rh935iit6ewrmw0unyul",
"download_url": "https://www.box.com/shared/static/rh935iit6ewrmw0unyul.jpeg",
"vanity_url": null,
"is_password_enabled": false,
"unshared_at": null,
"download_count": 0,
"preview_count": 0,
"access": "open",
"permissions": {
"can_download": true,
"can_preview": true
}
}
}

imageMediaMetadata date missing when jpg upload via web drive

Using the web client of Google Drive, I added a file image called "image.jpg." This was done by dragging the image from the file system (Mac OS.x 10.9.5) to Chrome where I have my drive folder ready to receive the file.
"image.jpg" has EXIF data such "Date Time Digitized" and "Date Time Original, as confirmed by using Preview on the Mac, and the Inspector tool. For sake of discussion, this date is: "Dec 6, 2014, 3:52:45 PM".
Upon making a call to the API such as:
https://www.googleapis.com/drive/v2/files/{fileId}
where fileId is the id of the file "image.jpg" in Drive, the resulting imageMediaMetadata does not contain date properties. Below is the imageMediaMetadata.
"imageMediaMetadata": {
"exposureTime": 0.053308000000000001,
"flashUsed": true,
"cameraMake": "Nokia",
"isoSpeed": 100,
"exposureMode": "Auto",
"colorSpace": "sRGB",
"height": 918,
"width": 1632,
"meteringMode": "Average",
"location": {
"latitude": 47.676632499999997,
"altitude": 0.0,
"longitude": -122.12224833333333
},
"aperture": 2.0,
"exposureBias": 0.0,
"rotation": 0,
"whiteBalance": "Auto",
"cameraModel": "Lumia 920"
}
"date" (imageMediaMetadata.date) is not there.
Why is "date" not in the imageMediaMetadata? How to resolve?
If possible, check your image file to see if it includes the Exif field: Exif/Image/DateTime. If it does not and you are able to add it, that would be a worthwhile test to see if it then produces a date in the metadata.

In Google Chrome, what is the extension api for changing the UserAgent and Device Metrics?

In Google Chrome, when viewing the developer tools, in the bottom right there is a Gear Icon that opens an additional Settings popup. One of the pages in the Settings popup is Overrides that contains User Agent and Device Metrics settings. I am trying to find the extensions API that is able to set those values programatically. Does such an API exist?
I've looked the main apis, and the experimental apis , but can't seem to find anything.
The sample for devtools.panels in the code samples doesn't seem to indicate how to 'explore' the existing devpanels either.
Specifically I'm trying to build simple extension available from a context menu in a Browser Action. It would act like a user-agent switcher, offering choices from the same list in the Settings popup, and automatically sets the Device Metrics to the values of the selected Agent. e.g. 640x960 for IPhone 4.
Any leads on how to programatically access the Settings popup
Some of the advanced features offered by the Developer tools can be accessed through the chrome.debugger API (add the debugger permission to the manifest file).
The User agent can be changed using the Network.setUserAgentOverride command:
// Assume: tabId is the ID of the tab whose UA you want to change
// It can be obtained via several APIs, including but not limited to
// chrome.tabs, chrome.pageAction, chrome.browserAction, ...
// 1. Attach the debugger
var protocolVersion = '1.0';
chrome.debugger.attach({
tabId: tabId
}, protocolVersion, function() {
if (chrome.runtime.lastError) {
console.log(chrome.runtime.lastError.message);
return;
}
// 2. Debugger attached, now prepare for modifying the UA
chrome.debugger.sendCommand({
tabId: tabId
}, "Network.enable", {}, function(response) {
// Possible response: response.id / response.error
// 3. Change the User Agent string!
chrome.debugger.sendCommand({
tabId: tabId
}, "Network.setUserAgentOverride", {
userAgent: 'Whatever you want'
}, function(response) {
// Possible response: response.id / response.error
// 4. Now detach the debugger (this restores the UA string).
chrome.debugger.detach({tabId: tabId});
});
});
});
The official documentation for the supported protocols and commands can be found here. As of writing, there's no documentation for changing the Device metrics. However, after digging in Chromium's source code, I discovered a file which defined all currently known commands:
chromium/src/out/Debug/obj/gen/webcore/InspectorBackendDispatcher.cpp
When I look through the list of definitions, I find Page.setDeviceMetricsOverride. This phrase seems to match our expectations, so let's search further, to find out how to use it:
Chromium code search: "Page.setDeviceMetricsOverride"
This yields "chromium/src/out/Release/obj/gen/devtools/DevTools.js" (thousands of lines). Somewhere, there's a line defining (beautified):
InspectorBackend.registerCommand("Page.setDeviceMetricsOverride", [{
"name": "width",
"type": "number",
"optional": false
}, {
"name": "height",
"type": "number",
"optional": false
}, {
"name": "fontScaleFactor",
"type": "number",
"optional": false
}, {
"name": "fitWindow",
"type": "boolean",
"optional": false
}], []);
How to read this? Well, use your imagination:
chrome.debugger.sendCommand({
tabId: tabId
}, "Page.setDeviceMetricsOverride",{
width: 1000,
height: 1000,
fontScaleFactor: 1,
fitWindow: false
}, function(response) {
// ...
});
I've tested this in Chrome 25 using protocol version 1.0, and it works: The tab being debugged is resized. Yay!

Chrome omnibox events without specific keywords?

I do want to check the content written in Chrome omnibox and redirect to the proper page.
Still, I cannot use specific keywords because I do want to redirect things like BUG-1234 to http://bugs.example.com/BUG-1234
I do have a regexp for this (as the BUG part can have lots of values).
How can I do this?
A chrome extension can help you, with help of Omnibox.
If i understood correctly when you enter BUG-1234 and hit Enter in Omnibox, your webpage URL Should be http://bugs.example.com/BUG-1234
Demonstration
I have used keyword as
"keyword": "BUG"
BUG, you can change it as per functionality. So when you enter B+U+G in chrome Omnibox , the search provider adds a custom layer as shown here
Image 1)
and when you enter 1234 and hit Enter or Select the suggested URL Open Bug %s ? in Omnibox, as shown here
Image 2)
It opens a web page with URL as shown here, where i used http://bugs.example.com as a test URL, which can be extended further.
Image 3)
manifest.json
Registered background Page and Omnibox with Chrome Extension, and added related permissions.
{
"name": "Bug Tracker",
"description": "This integrates chrome omnibox with bug search",
"version": "1",
"manifest_version": 2,
"background": {
"scripts": [
"background.js"
]
},
"omnibox": {
"keyword": "BUG"
},
"permissions": [
"<all_urls>"
]
}
background.js
Script for Custom Suggestions
//Set Text to show for custom suggested URL(s)
chrome.omnibox.setDefaultSuggestion({
"description": "Open Bug %s ?"
});
//Fired when Enter or a suggested Link is selected
chrome.omnibox.onInputEntered.addListener(function (bugId) {
//Use your custom URL
chrome.tabs.update({
"url": "http://bugs.example.com/BUG-" + bugId
}, function () {
console.log("Bug Page is open");
});
console.log("Input Entered is " + bugId);
});
References
Background Pages
Omnibox API
Manifest File