I am trying to retrieve metadata of a video file present in my google drive. I can access all the information related to that file (like size, mimetype, etc.). But, when I am trying to retrieve metadata of that video file I am getting a null value. Could you please tell me how can I retrieve metadata of a video file. Thanks in advance.
VideoMediaMetadata video_Media_MetaData=file.getVideoMediaMetadata();
AFAIK, a successful HTTP request using Files: list will return a response body which includes videoMediaMetadata in the following structure:
{
"kind": "drive#fileList",
"nextPageToken": string,
"incompleteSearch": boolean,
"files": [
"videoMediaMetadata": {
"width": integer,
"height": integer,
"durationMillis": long
},
"isAppAuthorized": boolean
]
}
However, please note that, as described in Files documentation, videoMediaMetadata is
Additional metadata about video media. This may not be available immediately upon upload.
Thus, it will return null for none as mentioned here.
With this, you may want to try Files: update to update a file's metadata and/or content with patch semantics.
Related
I am designing the rest apis that represent a file system.
File system support 3 functions
mkdir(path)
createFile(path, content) -> create if not exist and replace if exist.
readFile(path)
Here is the REST API, I am thinking of designing what do you guys think of it ?
1. mkdir
POST v1/file-system/directories
BODY {
"path" : "???"
}
RESPONSE
{
"id" : "",
"path" "",
"files": [...] // this will contain info on files or directories under this directory
}
2. createFile
PUT v1/file-system/files
BODY {
"path" : "???"
"content": ""
}
RESPONSE
{
"id" : "",
"content": ""
"path" ""
}
3. read
GET v1/file-system/files/{file-path} or
GET v1/file-system/files?file-path={file-path}
RESPONSE
{
"id" : "",
"content": ""
"path" ""
}
Can you guys tell me if these API'S are correct representation for these function.
Few questions
For GET API, shall I specify the path as path variable or query param ? If path then how will the backend differentiate between url path and file path.
e.g. v1/file-system/files/a/b/c.txt
Since create file can either create a file or replace the content of existing file, is it safe to use PUT ?
For POST and PUT, do we specify path as path variable ?
You have to understand that each request method (GET, POST, PUT...) has its own convention, but they do not differentiate a lot from each other.
For example, you could use POST to update something and not PATCH or so on.
At the end of the day, both methods, receive data in the body of the request and do something with it (or not).
Regarding your questions:
I would avoid sending a path as a query param. Send your data through the request body. That way you have a JSON and you don't have to care about specific encoding and character escaping for the URL.
Again, it is very safe since they only change because of the convention. We mostly use POST to create new data and PUT to create and replace data if it exists. Check this for more info.
Again, avoid putting paths as query params. Insert them into the body as JSON.
Read this article to learn more about HTTP Methods.
I have a requirement to extract the content of all the files store in a folder which can be of format pdf,worddoc,txt,msg,ppt etc. Now I need to store the content in elasticsearch.The solution needs to be build in pipeline architecture.I am planning to extract the content using Apache TIKA and then store it in elastic. Is there any better approach to implement this solution?
You should investigate the ingest attachment plugin which bundles Apache Tika and does exactly what you need, i.e. extracting content from PDF, DOC, PPT, etc.
Simply install it
bin/elasticsearch-plugin install ingest-attachment
Then you can create a new pipeline
PUT _ingest/pipeline/attachment
{
"description" : "Extract attachment information",
"processors" : [
{
"attachment" : {
"field" : "data"
}
}
]
}
Finally you can index your documents like this:
PUT my_index/my_type/my_id?pipeline=attachment
{
"data": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0="
}
You can find more usage information at https://www.elastic.co/guide/en/elasticsearch/plugins/5.3/using-ingest-attachment.html
I am trying to use the autodesk forge viewer tutorial
https://developer.autodesk.com/en/docs/model-derivative/v2/tutorials/prepare-file-for-viewer/
I have successfully uploaded and downloaded a dwg file
on the step where i convert it to svf it never seems to process and fails with
{"input":{"urn":"Safe Base64 encoded value of the output of the upload result"},"output":{"formats":[{"type":"svf","views":["2d","3d"]}]}}
HTTP/1.1 400 Bad Request
Result{"diagnostic":"Failed to trigger translation for this file."}
First question do i need to remove the urn: before Base64 encoding.
Second is there any more verbose error result that I can see.
Note I have also tried with a rvt file and tried with "type":"thumbnail" nothing seems to work.
I feel my Encoded URN is incorrect but I am not sure why it would be.
On the tutorial page they seem to have a much longer and raw urn not sure if I should be appending something else to it before encoding. they have a version and some other number
from tutorial
raw
"urn:adsk.a360betadev:fs.file:business.lmvtest.DS5a730QTbf1122d07 51814909a776d191611?version=12"
mine
raw
"urn:adsk.objects:os.object:gregbimbucket/XXX"
EDIT:
This is what i get back from the upload of a dwg file
HTTP/1.1 200 OK
Result{
"bucketKey" : "gregbimbucket",
"objectId" : "urn:adsk.objects:os.object:gregbimbucket/XXX",
"objectKey" : "XXX",
"sha1" : "xxxx",
"size" : 57544,
"contentType" : "application/octet-stream",
"location" : "https://developer.api.autodesk.com/oss/v2/buckets/gregbimbucket/objects/XXX"
}
This is what i send to convert the file
{"input":{"urn":"dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6Z3JlZ2JpbWJ1Y2tldC9YWFg"},"output":{"formats":[{"type":"svf","views":["2d","3d"]}]}}
This is the error I get back
HTTP/1.1 400 Bad Request
Result{"diagnostic":"Failed to trigger translation for this file."}
EDIT 2: SOLUTION
It looks like the object_id when uploading a file has to have the file extension and not end in a GUI or random set of characters for it to know what file type it is. So that it can be converted.
"objectId" : "urn:adsk.objects:os.object:gregbimbucket/Floor_sm.dwg",
SOLUTION It looks like the object_id when uploading a file has to have the file extension and not end in a GUI or random set of characters for it to know what file type it is.
https://developers.google.com/apps-script/guides/rest/api#parameter_and_return_types
When using the Google Execution Api for Java, the ID of the spreadsheet isn't very easy to understand. Here is the code snippet:
// Initialize parameters for that function.
String sheetId = "<ENTER_ID_OF_SPREADSHEET_TO_EXAMINE_HERE>";
List<Object> params = new ArrayList<Object>();
params.add(sheetId);
Any Ideas on how to locate this. I run the Sheets api to return the id of a SpreadSheet but it returns a link, and when I use the https://spreadsheets.google.com/feeds/spreadsheets/STRING or just the STRING itself I still get:
"code" : 404,
"errors" : [ {
"domain" : "global",
"message" : "Requested entity was not found.",
"reason" : "notFound"
Found this deep inside the Apps Script API reference.
A spreadsheet ID can be extracted from its URL. For example, the spreadsheet ID in the URL https://docs.google.com/spreadsheets/d/abc1234567/edit#gid=0 is "abc1234567".
https://developers.google.com/sheets/api/guides/concepts
states that:
Every API method requires a spreadsheetId parameter which is used to identify which spreadsheet is to be accessed or altered. This ID is the value between the "/d/" and the "/edit" in the URL of your spreadsheet. For example, consider the following URL that references a Google Sheets spreadsheet:
https://docs.google.com/spreadsheets/d/1qpyC0XzvTcKT6EISywvqESX3A0MwQoFDE8p-Bll4hps/edit#gid=0
The ID of this spreadsheet is 1qpyC0XzvTcKT6EISywvqESX3A0MwQoFDE8p-Bll4hps.
So I just pulled up my spreadsheet and looked at the URL to find my ID.
Hope this helps!
I just created a hyperlink to the sheets and then copied that hyperlink to a text file and the link line shows the GID.
https://docs.google.com/spreadsheets/d/1TxNHS6vuse1is2Mw_hUs9wTDM6f095Y6pKLeltUfNzQ/edit#gid=1049871492
Then I created a pull down list in A52 and then made =IF() logic to go to the GIDs to go to those sheets.
=IF(A52="47QTCK18D0001",HYPERLINK("#gid=0","47QTCK18D0001"),IF(A52="47QTCK18D0002",HYPERLINK("#gid=1049871492","47QTCK18D0002") ....
I am trying to add the source URL on an existing resource but I can't get it to work.
This is what I have:
HttpEntity reqEntity = MultipartEntityBuilder.create()
.addPart("id", new StringBody("resource id",ContentType.TEXT_PLAIN))
.addPart("Source", new StringBody("www.google.com",ContentType.TEXT_PLAIN))
.build();
postRequest = new HttpPost(host+"/api/3/action/resource_update");
postRequest.setEntity(reqEntity);
postRequest.setHeader("X-CKAN-API-Key", "myApi");
Which gives me the following error:
"success": false, "error": {"__type": "Validation Error", "url": ["Missing value"]}
I can add a Source field when I upload a file, but it doesn't create a link for it. Maybe because I use ContentType.TEXT_PLAIN instead of something that will tell CKAN that this is a link?
Edit:
By source I mean the link on the resource information where it points to the webpage of the original data. When manually uploading a file you have that option, I just cant get it to work with the API.
The error is telling you that you've not specified the url value for the resource, which is necessary.
The content that you POST needs to be in JSON format, whereas you appear to be sending it as multipart form data.
The JSON keys you need to send for a resource are id, url, name, format etc. i.e. you need to set url rather than Source. You can see the existing keys by looking at /api/action/resource_show?id=xyz.
The normal way to use resource_update is to do resource_show first, edit the JSON with the new values, and then resource_update. That way you don't lose any other properties of the resource, such as format.