How to get Uploaded Url of a Video File in android using Parse REST API - parse-platform

I am using Parse Mobile Backend for my android app,but whenever I want to upload a large video more than the default 10mb limit for a ParseFileby getting the bytes from it into a ParseFile I keep running into the dreaded OutOfMemory Exception .So,I want to use the Parse REST API since I can easily use the setChunkedStreamingMode(1024) in HttpUrlConnectionto send the bytes in a chunked manner.The trouble is,how do I get the uploaded url of the file uploaded.Thanks for your help in advance.

i think you can use getUrl() method
ParseFile file = new ParseFile(byte[] data);
file.getUrl();
ParseFile object has getUrl() method to getting url of file. this method return URL in string format.

Related

Spring Content 1.2.5 JPA(Postgres) .docx file mutates to zip archive

Saved ".docx" file with mimeType "application/vnd.openxmlformats-officedocument.wordprocessingml.document". But when I access it's endpoint in Spring Content and download it's not exactly Word document, but Zip archive(application/zip). Spring Content 1.2.5 supports ".docx" files, how can we fix it?
Demo project to reproduce issue(.docx file attached):
https://github.com/leonaugust/docx-problem
EDIT
Although I understand that resulting file is docx after all and we can choose to open it as Word document, but is there a way to make it less confusing for customers and return back as ".docx" format? In my case a huge amount of documents will most likely be sent in that format
As you have spring-content-rest on the classpath and use the #StoreRestResource annotation I am assuming that you are using that to fetch your content? Please let me know if that is not the case and I will edit.
There are a couple of annotations that, if present on the entity, the spring content rest post/put endpoints would set for you and that are then used later on by the GET endpoint; #MimeType and #OriginalFileName.
If you add these annotations to your entity and set them appropriately in your post endpoint then:-
#PostMapping
public UUID create(#RequestParam("file") MultipartFile multipartFile) {
File file = new File();
file.setMimeType(multipartFile.getContentType());
store.setContent(file, multipartFile.getResource());
file.setMimeType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
file.setOriginalFileName(multipartFile.getOriginalFilename());
UUID id = repository.save(file).getId();
log.info("id {}", id);
return id;
}
When your client fetches content (again, I assume) via the Spring Content REST endpoint it will set the following headers:
Content-type header
content-dispostion form-data attachment header
on the response.
Both of which will direct the browser app as to handle the content appropriately.
This should allow you to make the following get request from your browser.
curl -H 'Accept: application/vnd.openxmlformats-officedocument.wordprocessingml.document' http://localhost:8080/storage/b9ca6fbe-dede-4a51-b444-9e22b798e922
And it should download the attachments as test.docx
Seperately, I'd be curious to know why you added your own "create" endpoint, rather than using the Spring Data REST/Spring Content REST endpoint. It will do this for you automatically. I assume it is because you do not want to use Spring Data REST?

Unable to get content of file using google drive api

I am working with a react application where you can access google drive files using react-google-picker and I am using get api of google apis where you can pass "alt=media" as a URL parameter to get the file content. It's working as expected for text files but for PDF/Doc files, it returns metadata instead of actual content of file.
Is there any other way to get the content using google api's ??
this is the code for getting content of the file.
axios.get(`https://www.googleapis.com/drive/v2/files/${data.docs[0].id}?key=${developerKey}&alt=media`, {
headers: {
Authorization: Bearer ${this.state.token}
}
})

Full Media URL in Strapi

The Strapi API responds the media URLs as something like "url:'/uploads/thumbnail.png'".
I would like to get the complete URL that links to my file as value for "url". For example: "url:'https://example.org/uploads/thumbnail.png'"
The documentation also shows the full URL as response. How can I achieve this?
The full URLs come from using an upload provider such as AWS-S3 or Cloudinary. The local provider doesn't support full URLs at the moment.
There are some potentials reasons why you shouldn’t store a full URL, and respond with a full URL. I won’t dive into those reasons.
I suggest creating the entire request/response, or creating a middleware component to intercept the response.
Then you can modify the original url value with the site’s URL. Looping through the results with something like:
const serverHost = strapi.config.get('server.host', 'defaultValueIfUndefined');
url = serverHost + url;
See the following docs for more details:
https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations.html
https://docs.strapi.io/developer-docs/latest/development/backend-customization/middlewares.html#implementation

POST request in Windows phone

I am trying to get some data from the user and send it to my server for logging purposes. I was able to do it easily with jquery for my website. When I try to write a windows app for the same I am clueless as to how to post the data to my server.
So far I have fetched the data from the user and I am trying to use OpenWriteAsync function of webclient to send it to my server. I understand how OpenWriteAsync function works but I am not able to figure out how to send my own data.
My php script in my server will get values with name "FILENAME" and "FTIME" like,
$fname = $_POST['FILENAME'];
$time = $_POST['FTIME'];
So I have got this information from the user in two different string variables in c# inside my app. Now how do I send this to my server so that my php script gets this value and logs it inside my server.
I hope I am clear.
Take a look at UploadData method.
The way you use it something like this:
UploadData("http://abc.com","POST", "data in byte array");
Note: you need to convert data to byte array
Reference: http://msdn.microsoft.com/en-us/library/ktfa4fek(v=VS.90).aspx
You can do this by using the ContentType property in the HTTPWebRequest object.

send file from website to windows application

I have a file in the website and i m trying to send this file to windows application using the Response.BinaryWrite (getContent)( Where getContent is the byte array having the file which I need to send) vis HTTP post method only. Also I m adding a Header and Content-Type as application/octet-stream in the Response.
Now while reading the (httpWebResponse) response in the stream at client side(windows application) all the things (header + content-type + file + some extra bytes) are getting added. so when I try to read the file in stream it cannot be loaded since the content has chnged
Is there any way to separate the file from rest contents present in the response object..
How sahll I save this file in directory
Use System.Net.WebClient.DownloadData or DownloadFile method instead.
What language / version are you using?
If you are using a reasonably up-to-date version of C# you can use the WebClient class, and its DownloadFile method

Resources