Custom filepath on server parse.com - ios

I'm working with parse.com for my server end. I'm wondering if there's a way for files to be saved into subfolders. For example my file is currently saved with a url like this:
http://files.parsetfss.com/bb2767e6-fc18-4ff5-a071-199803c9aac2/tfss-d056e28e-1e02-49dd-930b-e46790a2e38d-Drums.png
is there a way I can get it to look like this instead:
http://files.parsetfss.com/bb2767e6-fc18-4ff5-a071-199803c9aac2/tfss-d056e28e-1e02-49dd-930b-e46790a2e38d/Drums.png
and for the same extension (tfss-d056e28e-1e02-49dd-930b-e46790a2e38d) apply to each row?
The reason I need this is because I'm actually uploading html files and it can't find its assets if they get renamed...

Have a look at the Cloud Hosting documentation here:
https://parse.com/docs/hosting_guide
Basically whatever files/folders you put in the "public" folder will be publicly available.
You can use it to upload files you want to be shared normally, instead of the way you described in your question which is for files you want to attach to objects.

Related

Upload file to the specified path (OneDrive)?

I prefer iOS code but the solutions in other languages may refer to this question too.
I use LiveSDK to access to OneDrive. Here is a link to the example which uses upload action (onClickUploadButton:)
But I can't understand how to specify the custom upload path - only default "me/skydrive" works. How do you solve the problem when you need to upload a concrete file to a concrete path which may not exist? Should I create all the folders separately and/or get their IDs to place a file exactly into them?

laravel 5.1 renaming file before uploading on s3

For safety reasons I would like to rename the files submitted to my application before uploading them to S3. For local storage I can use Storage::move afterwards. But for S3 I am having trouble. How do I do it? Also, instead of using move is it possible to rename them before storing? Right no my app renames the files without any actions to something like phpK69RGR.jpg May be I can just configure the random string method? I also tried using the php rename command before upload but my webservice started erroring out. I know its a very basic question but for some reason I am having trouble with it.
This is outlined in the docs.
$request->file('photo')->move($destinationPath, $fileName);
$fileName is an optional parameter that renames the file.
So with that, you could simply place this inside your controller:
//Generate random name
$fileName = str_random(30);
$request->file('photo')->move($destinationPath, $fileName);

Storing assets in cloud and read them securely

I am developing an iOS app that uses a large amount of images that are needed for animations for short videos. I want to save my application assets as static files in cloud and once they are needed download them using secure API call (either JSON, XML or any other alternative for that matter).
What is the best option for that. I have checked Parse, Dropbox, iCloud, Google Drive, but I am puzzled since I see only instructions for dynamic data that lets users access content they have created and not static assets.
What would be best option for that?
If you just want an easy way to serve static files I would take a look at Amazon S3. You can just upload files through the online console and then get the public URL to those files to use in your app. You can also use the S3 API to upload files through your web service or iOS app.
Hope this helps!
I'd go for Parse (basically because it is fast to learn and develop), you can create a table with the images and change the writing permissions if you are afraid somebody could modify the table.
Another option that you can check it's the special Config table so you can upload custom files (zip files i.e.) and download them in demand.

How to download a static excel file using Rails

I would like to provide a link to download a file via Rails. These are my questions:-
Where do you place the static file under public?
Are there any simple controls which allows me to download this file.
You don't need rails for this. If the file is in public, your web server should serve it automatically.
You just need to know the URL so that you can link to it from your app.
Doesnt really matter where you put it within public, but pick somewhere that will let you keep organized as you add more.

where is the best place to save images from users upload

I have a website that shows galleries. Users can upload their own content from the web (by entering a URL) or by uploading a picture from their computer.
I am storing the URL in the database which works fine for the first use case but I need to figure out where to store the actual images if a user does a upload from their computer.
Is there any recommendation here or best practice on where I should store these?
Should I save them in the appdata or content folders? Should they not be stored with the website at all because it's user content?
You should NOT store the user uploads anywhere they can be directly accessed by a known URL within your site structure. This is a security risk as users could upload .htm file and .js files. Even a file with the correct extension can contain malicious code that can be executed in the context of your site by an authenticated user allowing server-side or client-side attacks.
See for example http://www.acunetix.com/websitesecurity/upload-forms-threat.htm and What security issues appear when users can upload their own files? which mention some of the issues you need to be aware of before you allow users to upload files and then present them for download within your site.
Don't put the files within your normal web site directory structure
Don't use the original file name the user gave you. You can add a content disposition header with the original file name so they can download it again as the same file name but the path and file name on the server shouldn't be something the user can influence.
Don't trust image files - resize them and offer only the resized version for subsequent download
Don't trust mime types or file extensions, open the file and manipulate it to make sure it's what it claims to be.
Limit the upload size and time.
Depending on the resources you have to implement something like this, it is extremely beneficial to store all this stuff in Amazon S3.
Once you get the upload you simply push it over to Amazon and pop the URL in your database as you're doing with the other images. As mentioned above it would probably be wise to open up the image and resize it before sending it over. This both checks it is actually an image and makes sure you don't accidentally present a full camera resolution image to an end user.
Doing this now will make it much, much easier if you ever have to migrate/failover your site and don't want to sync gigabytes of image assets.
One way is to store the image in a database table with a varbinary field.
Another way would be to store the image in the App_Data folder, and create a subfolder for each user (~/App_Data/[userid]/myImage.png).
For both approaches you'd need to create a separate action method that makes it possible to access the images.
While uploading images you need to verify the content of the file before uploading it. The file extension method is not trustable.
Use magic number method to verify the file content which will be an easy way.
See the stackoverflow post and see the list of magic numbers
One way of saving the file is converting it to binary format and save in our database and next method is using App_Data folder.
The storage option is based on your requirement. See this post also
Set upload limit by setting maxRequestLength property to Web.Config like this, where the size of file is specified in KB
<httpRuntime maxRequestLength="51200" executionTimeout="3600" />
You can save your trusted data just in parallel of htdocs/www folder so that any user can not access that folder. Also you can add .htaccess authentication on your trusted data (for .htaccess you should kept your .htpasswd file in parallel of htdocs/www folder) if you are using apache.

Resources