Cannot Upload file to Alfresco with Curl - alfresco

I have a php script that uploads files to Alfresco using curl, it works fine with local setup of Alfresco on my system. But, fails when the same is used to upload to production copy.
Below, is the curl response upon failure while uploading file,
{
"status" :
{
"code" : 500,
"name" : "Internal Error",
"description" : "An error inside the HTTP server which prevented it from fulfilling the request."
},
"message" : "00031437 Unexpected error occurred during upload of new content.",
"exception" : "org.springframework.extensions.webscripts.WebScriptException - 00031437 Unexpected error occurred during upload of new content.",
"callstack" :
[
"" ,"java.lang.IllegalArgumentException: Class {}application\/pdf has not been defined in the data dictionary"
,"org.alfresco.repo.policy.ClassPolicyDelegate.get(ClassPolicyDelegate.java:98)"
,"org.alfresco.repo.policy.ClassPolicyDelegate.get(ClassPolicyDelegate.java:83)"
,"org.alfresco.repo.node.AbstractNodeServiceImpl.invokeBeforeCreateNode(AbstractNodeServiceImpl.java:283)"
,"org.alfresco.repo.node.db.DbNodeServiceImpl.createNode(DbNodeServiceImpl.java:363)"
,"sun.reflect.GeneratedMethodAccessor1147.invoke(Unknown Source)"
,"sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)"
,"java.lang.reflect.Method.invoke(Method.java:606)"
,"org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)"
,"org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)"
,"org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)"
,"org.alfresco.repo.tenant.MultiTNodeServiceInterceptor.invoke(MultiTNodeServiceInterceptor.java:104)"
,"org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)"
,"org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)"
,"com.sun.proxy.$Proxy9.createNode(Unknown Source)"
,"sun.reflect.GeneratedMethodAccessor1147.invoke(Unknown Source)"
,"sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)"
,"java.lang.reflect.Method.invoke(Method.java:606)"
.
.
.
}
Any idea?

The value of contenttype must be a valid type qname. Have a look at the documentation at http://WEBURL:8000/alfresco/service/index/uri/api/upload. If in doubt, try cm:content or it's full representation.

Related

Error while importing xray json format result using XRAY Cloud API {"error":"Test with key XX-XX not found."}

I am getting error {"error":"Test with key XX-XX not found."}, while uploading xray format json test result using xray cloud APICall
XRAY Cloud End point: https://xray.cloud.getxray.app/api/v2/import/execution?testExecKey=DMY-71.
Xray formatted Json:
{
"info" : {
"summary" : "Execution of automated tests",
"description" : "This execution is automatically created when importing execution results from an external source",
"project" : "DMY",
"version" : "v1.0",
"revision" : "1234",
"startDate" : "2022-07-25T11:47:35+01:00",
"finishDate" : "2022-07-25T11:48:35+01:00",
"testEnvironments": ["Chrome"]
},
"tests" : [
{
"testKey" : "DMY-67",
"start" : "2022-07-25T11:47:35+01:00",
"finish" : "2022-07-25T11:47:35+01:00",
"status" : "PASSED"
}
]
}
I can access TestKey in jira able to Update test case too.

mpdf temporary file directory is not writable when upload in server

When I run the file on my localhost it works, but when i upload it to my server using winSCP, I'm getting this error
PHP Fatal error: Uncaught Mpdf\MpdfException: Temporary files directory "E:\Inetpub\vhosts\gsm.org.my\httpdocs\print/custom/temp/dir/path" is not writable in E:\Inetpub\vhosts\gsm.org.my\httpdocs\print\vendor\mpdf\mpdf\src\Cache.php:17
Stack trace:
#1 E:\Inetpub\vhosts\gsm.org.my\httpdocs\print\vendor\mpdf\mpdf\src\Mpdf.php(1054): Mpdf\ServiceFactory->getServices(Object(Mpdf\Mpdf), Object(Psr\Log\NullLogger), Array, 0, Object(Mpdf\Language\LanguageToFont), Object(Mpdf\Language\ScriptToLanguage), NULL, NULL, NULL, NULL)
#2 E:\Inetpub\vhosts\gsm.org.my\httpdocs\print\print-form.php(88): Mpdf\Mpdf->__construct(Array)
#3 {main} thrown in E:\Inetpub\vhosts\gsm.org.my\httpdocs\print\vendor\mpdf\mpdf\src\Cache.php on line 17
Is it because the server couldn't find the file path or I wrote it wrong?
I tried giving permission on folder src but it said cannot change properties of file src. I am a beginner in this field. I tried search the solution on google regarding this error but I couldn't find anything.
In case you want to give mPDF another try:
it seems you are not providing the proper configuration to mPDF but we can't tell for sure as that part of your code (line 88 of your print-form.php) is missing. Taken from my last code using mPDF:
try {
$mpdf = new \Mpdf\Mpdf([
'tempDir' => __DIR__ . '/../tmp', // uses the current directory's parent "tmp" subfolder
'setAutoTopMargin' => 'stretch',
'setAutoBottomMargin' => 'stretch'
]);
} catch (\Mpdf\MpdfException $e) {
print "Creating an mPDF object failed with" . $e->getMessage();
}
Line 17 in Cache.php is part of the Cache constructor and throws an error in case the temporary directory is either not writable or not a directory:
// taken from method "createBasePath($basePath)"
if (!is_writable($basePath) || !is_dir($basePath)) {
return false;
}
To test if you see the error due to insufficient file permissions or a non-existing directory, upload a file with this content to your server and navigate to it with your preferred browser:
<?php
$pathToCheck= "E:\\Inetpub\\vhosts\\gsm.org.my\\httpdocs\\print//custom//temp//dir//path";
print 'Folder exists: '.(is_dir($pathToCheck) ? 'yes' : 'no').'<br />';
print 'Folder is writable: '.(is_writable($pathToCheck) ? 'yes' : 'no').'<br />';
You are on a Windows server so you will need to add the right user to the "tmp" folder under "Properties"->"Security", additionally check if the folder has the Attribute "Read-only" unticked.
Additional advice:
Please post relevant code in your future question (like the relevant portions of your print-form.php) as this reduces the risks of having to guess what might be the cause.

Meteor Amazon s3 delete image

I have successfully uploaded an image to amazon s3 with this meteor package
https://github.com/Lepozepo/S3 Now I am trying to delete the file, which I am getting a error on.
This is the documentation for the s3.delete code
S3.delete(path,callback)
This function permanently destroys a file located in your S3 bucket.
Parameters:
path: Must be in this format ("/folder/other_folder/file.extension").
So basically always start with "/" and never end with "/". This is
required.
callback: A function that is run after the delete operation
is complete returning an Error as the first parameter (if there is
one), and a Result as the second.
This is my upload and delete code
Template.postSubmit.events({
"click button.upload": function(){
var files = $("input.file_bag")[0].files
S3.upload({
files:files,
path:"uploads"
},function(e,r){
console.log(r);
delete_url = r.relative_url;
console.log(delete_url);
});
},
"click button.delete": function(){
S3.delete({
path:delete_url
},function(e,r){
console.log(e);
console.log(r);
});
}
});
The error I get when hitting the delete button.
errorClass {isClientSafe: true, error: 400, reason: "Match failed", details: undefined, message: "Match failed [400]", …}
details
:
undefined
error
:
400
errorType
:
"Meteor.Error"
isClientSafe
:
true
message
:
"Match failed [400]"
reason
:
"Match failed"
stack
:
"Error↵ at Connection._livedata_result (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:4823:23)↵ at onMessage (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:3528:206)↵ at http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:2908:9↵ at Array.forEach (<anonymous>)↵ at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?hash=cde485f60699ff9aced3305f70189e39c665183c:149:11)↵ at SockJS.self.socket.onmessage (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:2907:43)↵ at SockJS.REventTarget.dispatchEvent (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:142:28)↵ at SockJS._dispatchMessage (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:1309:14)↵ at SockJS._didMessage (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:1375:26)↵ at WebSocket.that.ws.onmessage (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:1531:21)"
__proto__
:
Error
Update
This is the error I got on the server in terminal side
Exception while invoking method '_s3_delete' Error: Match error: Expected string, got object
You should call it like this:
S3.delete(delete_url, function() { ... });
First parameter should be url itself, not the object like in your example.

INVALID_ARGUMENT (400 error) when calling Stackdriver Error Reporting API

When trying to invoke the Stackdriver Error Reporting API (via the API explorer or via the Client-Side JavaScript library), I receive the following error:
Request:
{ "message" : "test" }
Response:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
}
The Stackdriver Error Reporting API is enabled and I have Owner rights to the App Engine project.
Is the API simply not functional? If I'm doing something wrong, can someone try to help?
The documentation for reporting events says that a ServiceContext is required.
If you're only sending a message (not a stacktrace / exception) you'll need to include a context with a reportLocation as well. This is noted in the documentation of the message field, but it's not obvious.
The following works from the API explorer:
{
"context": {
"reportLocation": {
"functionName": "My Function"
}
},
"message": "error message",
"serviceContext": {
"service": "My Microservice",
}
}
You might be interested in the docs on How Error are Grouped too.
FWIW, I work on this product and I think the error message is too generic. The problem is (?) that the serving stack scrubs the message unless they're annotated as being for public consumption. I'll chase that down.

Artifactory API AQL "Displaying Specific Fields"

According to below link, Artifactory AQL allows "Displaying of specific fields" via REST API by returning only fields of interest.
https://www.jfrog.com/confluence/display/RTF/Artifactory+Query+Language#ArtifactoryQueryLanguage-DisplayingSpecificFields
It doesn't work if I provide a list of fields, see below
Not Work - Bad request (400)
items.find(...).include("name", "repo")
Works
items.find(...).include("*")
Can anyone advise
Thanks, Jag
I suspect that the problem is related to encoding during the REST call, therefore I suggest to upload the query as a file Here is a working example:
Save the following query to file, lets call it aql.query
items.find
(
{
"repo": {"$match":"*"}
}
)
.include("name","repo")
Run the following curl command from the same directory that contains the aql.query file and don't forget to replace the templates in the command with your user name, password, host and port.
curl -X POST -uuser:password 'http://host:port/artifactory/api/search/aql' -Taql.query
In the result you will get:
{
"results" :
[
{
"repo" : "ext-snapshot-local",
"name" : "maven-metadata.xml"
},{
"repo" : "ext-snapshot-local",
"name" : "multi-3.0.0-20150705.195404-1.pom"
},{
.
.
.
}
],
"range" :
{
"start_pos" : 0,
"end_pos" : 46,
"total" : 46
}
}
As you can see that the result contains only the "item repo" and the "item name" fields.
Had the same issue. Spent quite a bit of time trying to figure this out. Couldn't find an answer online.
With a bad request(400), I printed the response text: "For permissions reasons AQL demands the following fields: repo, path and name."
This solution worked for me -
at a minimum: have repo, path, name.
ie... items.find(...).include("name", "repo", "path", "created_by")

Resources