I am updating with AJAX the name of the file and in which folder it should be saved, the name is updated but the place destined to save (the folder) does not work.
What am I doing wrong?
url: "https://www.googleapis.com/drive/v3/files/D5Rs1c...",
data: JSON.stringify({
name: "name the drive",
parents: [{
kind: "drive#parentReference",
id: "1isO7RhgpuvNo-dkC0UJLrziGC..."
}]
}),
contentType: "application/json",
type: "PATCH"
From your endpoint of url: "https://www.googleapis.com/drive/v3/files/D5Rs1c...",, it seems that you are using Drive API v3. In this case, the filename and folder of the metadata are name: "samplename" and parents: ["folderId"], respectively. In your request body, parents: [{kind: "drive#parentReference",id: "1isO7RhgpuvNo-dkC0UJLrziGC..."}] is used while the filename is set as name: "name the drive". I think that this is the reason for your current issue. So, please modify your request body as follows.
From:
data: JSON.stringify({
name: "name the drive",
parents: [{
kind: "drive#parentReference",
id: "1isO7RhgpuvNo-dkC0UJLrziGC..."
}]
}),
To:
data: JSON.stringify({
name: "name the drive",
parents: ["1isO7RhgpuvNo-dkC0UJLrziGC..."]
})
Note:
If your folder of folder ID is in the shared Drive, please add a query parameter of supportsAllDrives=true to the endpoint.
Reference:
Files: update
Related
So I've built a Jekyll site with the theme [Moon](Failed to persist entry: TypeError: Cannot read property 'sha' of undefined) and I've uploaded it to my GitHub repository. Then I want to add Netlify's admin panel to my site so I follow this guide which I modify the config.yml to the following code:
backend:
name: git-gateway
publish_mode: editorial_workflow
media_folder: "files"
display_url: https://ccsource.org
slug:
encoding: "ascii"
clean_accents: true
collections:
- name: "story"
label: "Story"
folder: "_posts"
extension: "md"
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
create: true
fields:
- {label: "Layout", name: "layout", widget: "hidden", default: "post"}
- {label: "Title", name: "title", widget: "string"}
- label: "tags"
name: "tags"
widget: "list"
allow_add: true
default: ["story"]
- {label: "Summary", name: "excerpt", widget: "string", required: false}
- {label: "comments", name: "comments", widget: "hidden", default: true}
- label: "Publish date"
name: "date"
widget: "datetime"
default: ""
format: "MMM Do YY"
- {label: "Body", name: "body", widget: "markdown", required: true}
Since I got markdown sample file like:
---
layout: post
title: "Sample"
date: 2016-03-15
excerpt: "Hello..."
tag:
- sample
- post
- video
comments: true
---
# Sample
But after all things setup and deployed I visit my site's admin panel and try to create a new post I keep getting the following error.
Failed to persist entry: TypeError: Cannot read property 'sha' of undefined
And I've googled and modified the branch value to site which match to my github repository, but the error keeps showing, how can I fix it?
For anyone else experiencing this, the issue was that Netlify Identity was enabled, but Git Gateway, a sub-feature of Netlify Identity, was not. Instructions for enabling Git Gateway here: https://www.netlify.com/docs/git-gateway/#getting-started
I would like to use JSGrid as a way to both load data from a MySQL database, as well as save (new or edited) multiple rows of data via CakePHP 3. However, I'm unsure of how to do that, or whether that's possible.
For loading, I'd like to get the data from two connected tables if say I want to edit data. In CakePHP 3, I'd retrieve the data using a find and then setting it to the view, but I'm unsure how to go from there to put it into the JSGrid upon loading the view.
For saving similarly, I would save to two different tables. In CakePHP 3, normally for multiple tables, I'd use patch entity to save to the various tables, and AJAX to save things on another page without actually being on that page (the two add pages of the each of the tables). But I'm not sure if you can do that with multiples of data.
Eg.
$.post(".../users/add.json"
given the fields for users, will do what the add page would normally do, and patch entity with associated tables would save to the various associated tables, but only one at a time.
Update:
My config/routes.php:
Router::scope('/', function (RouteBuilder $routes) {
$routes->extensions(['json', 'xml']);
$routes->resources('Instrument');
}
My view:
<div id="jsGrid"></div>
<script>
var resources = [];
var instruments = [
{Name: "", Id: 0},
{Name: "Clarinet", Id: 1},
{Name: "Guitar", Id: 2},
{Name: "Piano", Id: 3},
{Name: "Violin", Id: 4},
];
$("#jsGrid").jsGrid({
controller: {
loadData: function (filter) {
return $.ajax({
type: "GET",
url: "<?= $basepath ?>/instrument/view/",
data: filter
});
},
insertItem: function (item) {
return $.ajax({
type: "POST",
url: "<?= $basepath ?>/instrument/add",
data: item
});
},
updateItem: function (item) {
return $.ajax({
type: "PUT",
url: "<?= $basepath ?>/instrument/edit",
data: item
});
},
deleteItem: function (item) {
return $.ajax({
type: "DELETE",
url: "<?= $basepath ?>/instrument/delete",
data: item
});
}
},
width: "100%",
height: "400px",
inserting: true,
editing: true,
sorting: true,
paging: true,
data: resources,
fields: [
{
name: "Instrument",
type: "select",
items: instruments,
valueField: "Id",
textField: "Name",
validate: "required",
width: 175
},
{name: "Comment", type: "text", width: 150},
{type: "control"}
]
});
</script>
<?= $basepath ?> is a variable set in my AppController that means regardless of the project name, I can still access URLs.
In the view, when I try to save a new line, the line is added, but the contents are blank. When I try to edit a line, I get a "Please wait", and then nothing gets saved, and I can still edit the fields. Also, in the console, I receive the following error:
http://localhost/<?= $basepath ?>/instrument/edit Failed to load resource: net::ERR_CONNECTION_RESET
I am having trouble referencing child assemblies that are required for a parent assembly translation.
First I POST to https://developer.api.autodesk.com/references/v1/setreference with the following body
{ master: 'urn:adsk.objects:os.object:stemn/57b9f339c77fe2652f830206-ckwdob3791d6u359wz7eklnmi.iam',
dependencies:
[ { file: 'urn:adsk.objects:os.object:stemn/57b9f339c77fe2652f830206-e3l7hokp0qxqn227b7qcjo47vi.iam',
metadata:
{ childPath: 'fuselage.iam',
parentPath: '57b9f339c77fe2652f830206-ckwdob3791d6u359wz7eklnmi.iam' } },
{ file: 'urn:adsk.objects:os.object:stemn/57b9f339c77fe2652f830206-mhrb7um0of74iasv37nzh0k9.iam',
metadata:
{ childPath: 'motor_mount.iam',
parentPath: '57b9f339c77fe2652f830206-ckwdob3791d6u359wz7eklnmi.iam' } } ] }
After setting references, I request translation and get the following result of the translation:
{ Result: 'Success',
Scope: '25660970-8194-4de0-baa4-c8f1f132b2a7',
RegisterType: [ 'thumbnail', '2dviewing', '3dviewing' ] }
After that I get the manifest for the urn and it is as follows:
{ guid: 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt',
owner: 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt',
type: 'design',
hasThumbnail: 'false',
startedAt: 'Wed Jan 04 04:43:59 UTC 2017',
urn: 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt',
region: 'US',
status: 'failed',
progress: 'complete',
success: '100%',
children:
[ { guid: 'aa85aad6-c480-4a35-9cbf-4cf5994a25ba',
messages:
[ { type: 'warning',
message: 'The drawing\'s thumbnails were not properly created.',
code: 'TranslationWorker-ThumbnailGenerationFailed' } ],
name: '57b9f339c77fe2652f830206-ckwdob3791d6u359wz7eklnmi.iam',
success: '100%',
hasThumbnail: 'false',
role: 'viewable',
version: '2.0',
urn: 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt',
status: 'failed',
assetCount: 25,
type: 'folder',
progress: 'complete',
children:
[ { guid: '015896d9-e6d3-4be6-8f3d-96da5e64eed3',
type: 'folder',
name: 'Scenes',
status: 'success',
progress: 'complete',
success: '100%',
hasThumbnail: 'false',
children:
[ { guid: '451f7aab-1917-40dd-b117-5dd8f90ab6a7',
type: 'geometry',
role: '3d',
name: 'Scene',
status: 'success',
messages:
[ { type: 'warning',
code: 'ATF-1023',
message:
[ 'The file: {0} does not exist.',
'X:\\Google Drive\\SCAAD\\PRJ_HAARDCraft\\HAARDCraft_JFlight\\CAD\\Fuselage\\fuselage.iam' ] },
{ type: 'warning',
code: 'ATF-1023',
message:
[ 'The file: {0} does not exist.',
'X:\\Google Drive\\SCAAD\\PRJ_HAARDCraft\\HAARDCraft_JFlight\\CAD\\Engine mount\\motor_mount.iam' ] },
{ type: 'error',
code: 'ATF-1026',
message:
[ 'The file: {0} is empty.',
'C:/worker/viewing-inventor-lmv/tmp/job-1/68/output/1/57b9f339c77fe2652f830206-ckwdob3791d6u359wz7eklnmi.svf' ] } ],
size: 27864,
progress: 'complete',
success: '100%',
hasThumbnail: 'false',
children:
[ { guid: '6dc4b244-8a47-4a75-bcb3-811dc7b4f294',
type: 'resource',
urn: 'urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt/output/1/57b9f339c77fe2652f830206-ckwdob3791d6u359wz7eklnmi.svf',
role: 'graphics',
mime: 'application/autodesk-svf',
size: 27864 } ] },
{ guid: '9bb1adbe-d9d9-4482-ac03-1d60bb0aea36',
type: 'resource',
urn: 'urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt/output/1/properties.db',
role: 'Autodesk.CloudPlatform.PropertyDatabase',
mime: 'application/autodesk-db',
status: 'success',
size: 24576 } ] },
{ guid: '039c2bcf-beb7-426b-916c-4a5adb814593',
type: 'resource',
role: 'Autodesk.CloudPlatform.DesignDescription',
urn: 'urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt/output/xref/designDescription.json',
mime: 'application/json' } ] } ] }
Using the same code path I can successfully render an assembly with non-assembly child parts that have been set using setreference, but when rendering an assembly with child assemblies, setreference doesn't seem to set the references to the child assembly files successfully. Is there something wrong in my sequence for setting references to child assemblies?
I discussed with #sabrehage and finally got the working codes.
firstly, it is recommended to use Forge Derivative API v2 (zip + specify root file only), by which, the API user does not need to specify the references explicitly.
If you still want to use Forge Derivative API v1, the following is the note:
In local Inventor, the file references are managed by Inventor Project. Inventor will look for the ref files firstly in the specific folders of the Project, then look for the relative paths. Obviously, when the files are uploaded to bucket of Forge, no project file, all files are in the same level in physical perspective. So in v1, it depends on the reference file that the sender specifies.
If the hierarchy is like:
Top Assembly.iam
part1.ipt
part2.ipt
The reference file can be simply composed like what is mentioned in the blog:
http://adndevblog.typepad.com/cloud_and_mobile/2015/09/how-to-set-references-with-inventor-files-for-view-and-data-api.html.
In the dataset of #sabrehagen, the hierarchy contains nested assemblies, even in sub folder:
topassemb.iam
part in top assemb.ipt
subassem folder
subassem.iam
part1 in sub assem1.ipt
part2 in sub assem1.ipt
The correct way is to specify in one call (for top assembly only), and specify the subfolder in the reference map. In addition, we should define path name with original name, instead of that has been URL encoded. i.e.
{
"master" : "urn:adsk.objects:os.object:adsk2017-8/topassemb.iam",
"dependencies" : [
{
"file" : "urn:adsk.objects:os.object:adsk2017-8/subassem.iam",
"metadata" : {
"childPath" : "subassem/subassem.iam",
"parentPath" : "topassemb.iam"
}
},
{
"file" : "urn:adsk.objects:os.object:adsk2017-8/part1%20in%20sub%20assem1.ipt",
"metadata" : {
"childPath" : "part1 in sub assem1.ipt",
"parentPath" : "subassem/subassem.iam"
}
},
{
"file" : "urn:adsk.objects:os.object:adsk2017-8/part2%20in%20sub%20assem1.ipt",
"metadata" : {
"childPath" : "part2 in sub assem1.ipt",
"parentPath" : "subassem/subassem.iam"
}
},
{
"file" : "urn:adsk.objects:os.object:adsk2017-8/part%20in%20top%20assemb.ipt",
"metadata" : {
"childPath" : "part in top assemb.ipt",
"parentPath" : "topassemb.iam"
}
}
]
}
If without specifying subfolder, Forge thinks all files are within the same level, but it conflicts to the hierarchy of the last saving (absolute path). So it failed to find the corresponding files in the bucket.
After Forge gets the files and correct reference, it will look at the reference file and create the subfolders if they are specified, then put those files to the subfolder from bucket, finally translate.
as I remember, you would also need to configure the parts in the web service of set reference. This is a blog: http://adndevblog.typepad.com/cloud_and_mobile/2015/09/how-to-set-references-with-inventor-files-for-view-and-data-api.html. probably it could help you to diagnose the issue.
But, I strongly suggest you migrate to v2, by which you do not need to set reference manually. you can just upload all dataset as a zip file and set which file is the top (root) file, Forge will analyze the hierarchy automatically. This is another blog: http://adndevblog.typepad.com/cloud_and_mobile/2016/07/translate-referenced-files-by-derivative-api.html
I use ExtJS 4.2.2. A store for browsing and managing folders is defined like this:
Ext.define('hds.store.CaseFolders', {
extend: 'Ext.data.Store',
requires: [
'app.model.Folder',
'Ext.data.proxy.Rest',
'Ext.data.reader.Json',
'Ext.data.writer.Json'
],
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: false,
model: 'app.model.Folder',
storeId: 'Folders',
proxy: {
type: 'rest',
url: '/api/folders.json',
reader: {
type: 'json',
messageProperty: 'message',
root: 'data'
},
writer: {
type: 'json',
writeAllFields: false,
root: 'data'
}
}
}, cfg)]);
}
});
It uses this model:
Ext.define('app.model.Folder', {
extend: 'Ext.data.Model',
requires: [
'Ext.data.Field'
],
fields: [
{
name: 'name',
type: 'string'
},
{
name: 'parentId',
type: 'int'
},
{
name: 'type',
type: 'string'
}
]
});
Folders can be added, renamed and removed.
When changing the name of the folder, for example and using store.sync(), the record is properly synced to the server with a PUT containing id and name attributes.
However, when deleting the folder, store.sync() doesn't send any request to the server. A callback function was added to sync, but it is not called at all.
It seems that the REST store (proxy?) "thinks" that there is nothing to sync to the server.
Why is it like that?
Found the reason for the problem that I had:
The store is filtered to show content of the folder to be deleted.
When wanting to delete current folder, its record is filtered away.
Adding a line to remove filters before removing the parent folder record solved the problem.
I am trying to use Ext JS 4 and was playing with one of the grid examples and wanted to use JSON rather than XML. No mater how I code the JSON data, I get no records to load.
Here is my code:
Ext.define('Plant', {
extend: 'Ext.data.Model',
fields: [{
name: 'common',
type: 'string'
}, {
name: 'botanical',
type: 'string'
}, {
name: 'light'
}, ]
});
// Create the Data Store.
var store = Ext.create('Ext.data.Store', {
// Destroy the store if the grid is destroyed.
autoDestroy: true,
model: 'Plant',
proxy: {
type: 'ajax',
url: 'plants.json',
reader: {
type: 'json',
root: 'records'
}
},
sorters: [{
property: 'common',
direction: 'ASC'
}]
});
Here is my data:
{
"records": [
{
"common": "Bloodroot",
"botanical": "Sanguinaria canadensis",
"light": "Mostly Shady"
}, {
"common": "test",
"botanical": "I do not know",
"light": "Mostly Shady"
}
]
}
The XML reader works great, but we want to use JSON.
Thanks in advance
Have a look at this thread! You need to check your url path to plants.json, path starts from 'index.html' or some other similar starting point , and not the .js file where store is located. I tested your code and it works fine, also use autoLoad:true in your Ext.data.Store, i dont see your grid code so.. Cheers!