Interface
I have a few file upload, then how to upload all the file only for input that have files.
DO i need to upload one by one or push all in one array, then save the data using the array.
any suggestion ?
Related
Is it possible to transfer a picture from the back to the front as a Upload file? How to transfer file from back to front?
What I did to transfer the image from front to back:
Adding a new data type for a file:
Next, you will need to define scalar Upload in the sсhema.graphqls file:
The most important thing is not to forget to write the method in Mutations in the sсhema.graphqls file:
Look, I get javax.servlet.http.Part when I upload a photo. At the front we get the data through the Apollo hook useQuery/useMutation
But how do I send the photo back to the front?
After all, javax.servlet.http.Part is not transferred to the front?
How to write a method signature in the sсhema.graphqls file in Query section and in the implementation of this method in GraphQLMutationResolver implemented class?
I need to transfer the file. If the GraphQl team sees this message, please write more documentation on this topic.
I have a firebase function which given some arguments creates a "post" with a title and the such. Is there a way to send an image as an argument which can then be processed by firebase functions and then upload to firebase storage.
I think it is possible by decoding the file/image object to a base64 string which could be then sent as an argument. How would I convert the file object from html file input to base64? On the other side how would firebase functions know that the string is an actual image? How can I tell the size of the image? Is there a limit to the size of arguments given to a firebase callable function?
I ditched this question but came across the problem later in a different project. So to anyone seeing it is possible through base 64 strings. It has the restraints that the image cannot be bigger than 10mb but it is easier than trying to "catch" the file after it being uploaded directly.
Here is the solution
I would do the following:
Let the user upload the file directly into firebase storage in a folder where only the user has access to.
Let a function trigger on upload that takes this image, checks if the user is authorized to put that in the target folder and put the file in there (or whatever you want the function to do exactly).
I have a form on jsp and it has two file inputs, one to upload profile picture and one to upload PDF file.
I want to validate that
image input should accept only .jpeg or .png and its size should not exceed 200KB.
PDF input should be only PDF and size should not be more than 2MB.
How can I put different validations for different files in the same form ?
File limitations are request-related. If you need two different settings to be applied, you'd need two different requests (hence two forms), that is obviously not the wanted solution.
Then you can easily overcome this by applying:
in struts.xml the file type (image types, pdf)
in struts.xml the 2MB limit (the higher of the two)
in action validate(), or in XML validation, or in annotation validation, a control like "if file is of type image and size > 200KB, raise an error".
EDIT:
By the way i did it by writing my own interceptor.
Of course, if you have to apply this logic to many actions, then a custom Interceptor helps you DRY.
Just ensure you've understood how validation works, and add field errors from within your Interceptor in case it fails, so that the INPUT result will be automatically returned by the Worflow Interceptor.
I have a fineuploader that allows multiple files to be uploaded in MVC web app.
Example:
Suppose I upload 3 files 5MB, 20MB, 1MB
I expect 3 files to arrive in the controller in single call but they are not.
I want to iterate all 3 files (array) and process
Question 1: Is there a way to get all 3 files at once in the server?
[HttpPost]
public FineUploaderResult UploadFile(FineUpload upload)
{
//upload contains only one file at a time
//for second file it gets call again even though I submit only once
}
No. Fine Uploader sends each file in a separate request. This is not currently configurable. If you need to tie your files together, you can easily do that by passing common parameters with each file via the params option, or the setParams API method. Sever-side, you can look for this common parameter in each upload POST request and deal with the files accordingly.
I'm using Services 3 to create a custom service that will create or update a specific content type (similar to the built-in Node Service). The content type uses CCK for a few fields, mainly an image (file) upload field. I have no problem connecting to the service and creating a new node by setting the text parameters (including some CCK fields), but I can't figure out how to handle submitting a file.
I've tried base64 encoding the jpg then passing it as a parameter using the same field name as the node creation form uses, files[field_um_high_res_0]. I've also tried submitting a multipart form.
Any ideas?
Thanks,
Howie
Looks like all I had to do was encode the file as base64 then use the file resource to create a new file in the system and take the resultant fid and use it to load the new file object which is passed as the value of the CCK file field.
So it looks like this:
my_cck_file_field_name[0] = the_file_object